From: erickson Date: Tue, 18 Mar 2008 16:12:46 +0000 (+0000) Subject: implemented hard hold ceilings and basis for soft ceilings X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9e690a9affcafb866c8d81889b43e598ec1e6ef4;p=Evergreen.git implemented hard hold ceilings and basis for soft ceilings git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@9070 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index 4e164ad530..428cdf746d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -966,6 +966,14 @@ sub fetch_captured_holds { } } +sub find_hold_ceilings { + my $org = shift; + return ( + $U->ou_ancestor_setting_value($org, OILS_SETTING_HOLD_SOFT_CEILING), + $U->ou_ancestor_setting_value($org, OILS_SETTING_HOLD_HARD_CEILING) + ); +} + __PACKAGE__->register_method( method => "check_title_hold", @@ -988,7 +996,7 @@ sub check_title_hold { my $titleid = $params{titleid} ||""; my $volid = $params{volume_id}; my $copyid = $params{copy_id}; - my $mrid = $params{mrid} ||""; + my $mrid = $params{mrid} ||""; my $depth = $params{depth} || 0; my $pickup_lib = $params{pickup_lib}; my $hold_type = $params{hold_type} || 'T'; @@ -1006,12 +1014,44 @@ sub check_title_hold { return OpenILS::Event->new('PATRON_BARRED') if $U->is_true($patron->barred); - my $rangelib = $params{range_lib} || $patron->home_ou; - my $request_lib = $e->retrieve_actor_org_unit($e->requestor->ws_ou) or return $e->event; - $logger->info("checking hold possibility with type $hold_type"); + my($soft_ceiling, $hard_ceiling) = find_hold_ceilings($selection_ou); + + if(defined $hard_ceiling and $$params{depth} < $hard_ceiling) { + $logger->info("performing hold possibility check with hard ceiling $hard_ceiling"); + if(do_possibility_checks($e, $patron, $request_lib, $hard_ceiling, %params)) { + return {success => 1, depth => $hard_ceiling} + } else { + return {success => 0}; + } + + } elsif(defined $soft_ceiling) { + $logger->info("performing hold possibility check with soft ceiling $soft_ceiling"); + # XXX soft ceilings. work up the tree until a potential copy is found + + } else { + $logger->info("performing hold possibility check with no ceiling"); + if(do_possibility_checks($e, $patron, $request_lib, $params{depth}, %params)) { + return {success => 1, depth => $hard_ceiling}; + } else { + return {success => 0}; + } + } +} + +sub do_possibility_checks { + my($e, $patron, $request_lib, $depth, %params) = @_; + + my $titleid = $params{titleid} ||""; + my $volid = $params{volume_id}; + my $copyid = $params{copy_id}; + my $mrid = $params{mrid} ||""; + my $pickup_lib = $params{pickup_lib}; + my $hold_type = $params{hold_type} || 'T'; + my $selection_ou = $params{selection_ou} || $pickup_lib; + my $copy; my $volume; @@ -1035,12 +1075,12 @@ sub check_title_hold { or return $e->event; return _check_volume_hold_is_possible( - $volume, $title, $rangelib, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou); + $volume, $title, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou); } elsif( $hold_type eq OILS_HOLD_TYPE_TITLE ) { return _check_title_hold_is_possible( - $titleid, $rangelib, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou); + $titleid, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou); } elsif( $hold_type eq OILS_HOLD_TYPE_METARECORD ) { @@ -1048,49 +1088,12 @@ sub check_title_hold { my @recs = map { $_->source } @$maps; for my $rec (@recs) { return 1 if (_check_title_hold_is_possible( - $rec, $rangelib, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou)); + $rec, $depth, $request_lib, $patron, $e->requestor, $pickup_lib, $selection_ou)); } return 0; } } - - -sub ___check_title_hold_is_possible { - my( $titleid, $rangelib, $depth, $request_lib, $patron, $requestor, $pickup_lib ) = @_; - - my $limit = 10; - my $offset = 0; - my $title; - - $logger->debug("Fetching ranged title tree for title $titleid, org $rangelib, depth $depth"); - - while( $title = $U->storagereq( - 'open-ils.storage.biblio.record_entry.ranged_tree', - $titleid, $rangelib, $depth, $limit, $offset ) ) { - - last unless - ref($title) and - ref($title->call_numbers) and - @{$title->call_numbers}; - - for my $cn (@{$title->call_numbers}) { - - $logger->debug("Checking callnumber ".$cn->id." for hold fulfillment possibility"); - - for my $copy (@{$cn->copies}) { - $logger->debug("Checking copy ".$copy->id." for hold fulfillment possibility"); - return 1 if verify_copy_for_hold( - $patron, $requestor, $title, $copy, $pickup_lib, $request_lib ); - $logger->debug("Copy ".$copy->id." for hold fulfillment possibility failed..."); - } - } - - $offset += $limit; - } - return 0; -} - my %prox_cache; sub create_ranged_org_filter { @@ -1118,7 +1121,7 @@ sub create_ranged_org_filter { sub _check_title_hold_is_possible { - my( $titleid, $rangelib, $depth, $request_lib, $patron, $requestor, $pickup_lib, $selection_ou ) = @_; + my( $titleid, $depth, $request_lib, $patron, $requestor, $pickup_lib, $selection_ou ) = @_; my $e = new_editor(); my %org_filter = create_ranged_org_filter($e, $selection_ou, $depth); @@ -1231,7 +1234,7 @@ sub _check_title_hold_is_possible { sub _check_volume_hold_is_possible { - my( $vol, $title, $rangelib, $depth, $request_lib, $patron, $requestor, $pickup_lib, $selection_ou ) = @_; + my( $vol, $title, $depth, $request_lib, $patron, $requestor, $pickup_lib, $selection_ou ) = @_; my %org_filter = create_ranged_org_filter(new_editor(), $selection_ou, $depth); my $copies = new_editor->search_asset_copy({call_number => $vol->id, %org_filter}); $logger->info("checking possibility of volume hold for volume ".$vol->id); @@ -1286,7 +1289,7 @@ sub find_nearest_permitted_hold { for my $h (@$old_holds) { return ($h) if $h->hold_type eq 'R'; } - my $hold_stall_interval = $U->ou_ancestor_setting_value($user->ws_ou, 'circ.hold_stalling.soft'); + my $hold_stall_interval = $U->ou_ancestor_setting_value($user->ws_ou, OILS_SETTING_HOLD_SOFT_STALL); $logger->info("circulator: searching for best hold at org ".$user->ws_ou. " and copy $bc with a hold stalling interval of ". ($hold_stall_interval || "(none)")); diff --git a/Open-ILS/src/perlmods/OpenILS/Const.pm b/Open-ILS/src/perlmods/OpenILS/Const.pm index 46dadeb92b..2621dc1d70 100644 --- a/Open-ILS/src/perlmods/OpenILS/Const.pm +++ b/Open-ILS/src/perlmods/OpenILS/Const.pm @@ -77,6 +77,10 @@ econst OILS_SETTING_DEF_ITEM_PRICE => 'cat.default_item_price'; econst OILS_SETTING_ORG_BOUNCED_EMAIL => 'org.bounced_emails'; econst OILS_SETTING_CHARGE_LOST_ON_ZERO => 'circ.charge_lost_on_zero'; econst OILS_SETTING_VOID_OVERDUE_ON_LOST => 'circ.void_overdue_on_lost'; +econst OILS_SETTING_HOLD_SOFT_STALL => 'circ.hold_stalling.soft'; +econst OILS_SETTING_HOLD_HARD_STALL => 'circ.hold_stalling.hard'; +econst OILS_SETTING_HOLD_SOFT_CEILING => 'circ.hold_ceiling.soft'; +econst OILS_SETTING_HOLD_HARD_CEILING => 'circ.hold_ceiling.hard'; diff --git a/Open-ILS/web/opac/skin/default/js/holds.js b/Open-ILS/web/opac/skin/default/js/holds.js index 652e6f9a74..d987804532 100644 --- a/Open-ILS/web/opac/skin/default/js/holds.js +++ b/Open-ILS/web/opac/skin/default/js/holds.js @@ -734,8 +734,8 @@ function holdHandleCreateResponse(r, recurse) { if(!recurse) { var res = r.getResultObject(); - if(!res || checkILSEvent(res) ) { - if(!res) { + if(checkILSEvent(res) || res.success != 1) { + if(res.success != 1) { alert($('hold_not_allowed').innerHTML); } else { if( res.textcode == 'PATRON_BARRED' ) { @@ -747,6 +747,7 @@ function holdHandleCreateResponse(r, recurse) { swapCanvas($('holds_box')); return; } + r._hold.selection_depth(res.depth); } holdCreateHold(r._recurse, r._hold);