From: erickson Date: Thu, 14 Sep 2006 17:43:38 +0000 (+0000) Subject: added ability to do hold possibility checks for copy/volume holds - checking on all... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=aa8f83cc9d6f68df241c4856f72040b1b1fdc831;p=evergreen%2Fpines.git added ability to do hold possibility checks for copy/volume holds - checking on all from opac now git-svn-id: svn://svn.open-ils.org/ILS/trunk@6103 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 5113d6dca8..b4b8c45323 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -1060,6 +1060,8 @@ sub check_title_hold { my %params = %$params; my $titleid = $params{titleid} ||""; + my $volid = $params{volume_id}; + my $copyid = $params{copy_id}; my $mrid = $params{mrid} ||""; my $depth = $params{depth} || 0; my $pickup_lib = $params{pickup_lib}; @@ -1084,18 +1086,46 @@ sub check_title_hold { my $request_lib = $e->retrieve_actor_org_unit($e->requestor->ws_ou) or return $e->event; - if( $hold_type eq 'T' ) { + $logger->info("checking hold possibility with type $hold_type"); + + my $copy; + my $volume; + my $title; + + if( $hold_type eq OILS_HOLD_TYPE_COPY ) { + + $copy = $e->retrieve_asset_copy($copyid) or return $e->event; + $volume = $e->retrieve_asset_call_number($copy->call_number) + or return $e->event; + $title = $e->retrieve_biblio_record_entry($volume->record) + or return $e->event; + return verify_copy_for_hold( + $patron, $e->requestor, $title, $copy, $pickup_lib, $request_lib ); + + } elsif( $hold_type eq OILS_HOLD_TYPE_VOLUME ) { + + $volume = $e->retrieve_asset_call_number($volid) + or return $e->event; + $title = $e->retrieve_biblio_record_entry($volume->record) + or return $e->event; + + return _check_volume_hold_is_possible( + $volume, $title, $rangelib, $depth, $request_lib, $patron, $e->requestor, $pickup_lib); + + } elsif( $hold_type eq OILS_HOLD_TYPE_TITLE ) { + return _check_title_hold_is_possible( $titleid, $rangelib, $depth, $request_lib, $patron, $e->requestor, $pickup_lib); - } - if( $hold_type eq 'M' ) { + } elsif( $hold_type eq OILS_HOLD_TYPE_METARECORD ) { + my $maps = $e->search_metabib_source_map({metarecord=>$mrid}); 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)); } + return 0; } } @@ -1124,20 +1154,9 @@ sub _check_title_hold_is_possible { $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 OpenILS::Utils::PermitHold::permit_copy_hold( - { patron => $patron, - requestor => $requestor, - copy => $copy, - title => $title, - title_descriptor => $title->fixed_fields, # this is fleshed into the title object - pickup_lib => $pickup_lib, - request_lib => $request_lib - } - ); - + 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..."); } } @@ -1147,6 +1166,35 @@ sub _check_title_hold_is_possible { return 0; } +sub _check_volume_hold_is_possible { + my( $vol, $title, $rangelib, $depth, $request_lib, $patron, $requestor, $pickup_lib ) = @_; + my $copies = new_editor->search_asset_copy({call_number => $vol->id}); + $logger->info("checking possibility of volume hold for volume ".$vol->id); + for my $copy ( @$copies ) { + return 1 if verify_copy_for_hold( + $patron, $requestor, $title, $copy, $pickup_lib, $request_lib ); + } + return 0; +} + + + +sub verify_copy_for_hold { + my( $patron, $requestor, $title, $copy, $pickup_lib, $request_lib ) = @_; + $logger->info("checking possibility of copy in hold request for copy ".$copy->id); + return 1 if OpenILS::Utils::PermitHold::permit_copy_hold( + { patron => $patron, + requestor => $requestor, + copy => $copy, + title => $title, + title_descriptor => $title->fixed_fields, # this is fleshed into the title object + pickup_lib => $pickup_lib, + request_lib => $request_lib + } + ); + return 0; +} + sub find_nearest_permitted_hold { @@ -1205,6 +1253,10 @@ sub find_nearest_permitted_hold { } + + + + __PACKAGE__->register_method( method => 'all_rec_holds', api_name => 'open-ils.circ.holds.retrieve_all_from_title', @@ -1258,6 +1310,8 @@ sub all_rec_holds { + + __PACKAGE__->register_method( method => 'uber_hold', api_name => 'open-ils.circ.hold.details.retrieve' diff --git a/Open-ILS/web/opac/skin/default/js/holds.js b/Open-ILS/web/opac/skin/default/js/holds.js index b7b6cc623f..a96900ce4e 100644 --- a/Open-ILS/web/opac/skin/default/js/holds.js +++ b/Open-ILS/web/opac/skin/default/js/holds.js @@ -541,10 +541,21 @@ function holdsSetSelectedFormats() { function holdsCheckPossibility(pickuplib, hold, recurse) { - var rec = holdArgs.record; - var type = holdArgs.type; - var req = new Request(CHECK_HOLD_POSSIBLE, G.user.session, - { titleid : rec, patronid : G.user.id(), depth : 0, pickup_lib : pickuplib } ); + + var args = { + titleid : holdArgs.record, + volume_id : holdArgs.volume, + copy_id : holdArgs.copy, + hold_type : holdArgs.type, + patronid : G.user.id(), + depth : 0, + pickup_lib : pickuplib + }; + + _debug("hold possible args = "+js2JSON(args)); + + var req = new Request(CHECK_HOLD_POSSIBLE, G.user.session, args ); + req.request.alertEvent = false; req.request._hold = hold; req.request._recurse = recurse; @@ -636,45 +647,13 @@ function holdsBuildHoldFromWindow() { hold.holdable_formats(fstring); hold.target(holdArgs.metarecord); } - - //alert(fstring); return; - - /* - if(isXUL()) - hold.selection_depth(getSelectorVal($('holds_depth_selector'))); - */ - return hold; } function holdsPlaceHold(hold, recurse) { - if(!hold) return; - swapCanvas($('check_holds_box')); - - if( holdArgs.type == 'M' || holdArgs.type == 'T' ) { - var res = holdsCheckPossibility(hold.pickup_lib(), hold, recurse); - - /* - if(!res || checkILSEvent(res) ) { - if(!res) { - alert($('hold_not_allowed').innerHTML); - } else { - if( res.textcode == 'PATRON_BARRED' ) { - alertId('hold_failed_patron_barred'); - } else { - alert($('hold_not_allowed').innerHTML); - } - } - swapCanvas($('holds_box')); - return; - } - */ - - } else { - holdCreateHold(recurse, hold); - } + holdsCheckPossibility(hold.pickup_lib(), hold, recurse); }