use parent qw/OpenILS::Application::Storage::Publisher/;
use strict;
use warnings;
-use OpenSRF::Utils::Logger qw/:level/;
+use OpenSRF::Utils::Logger qw/:level :logger/;
use OpenSRF::Utils qw/:datetime/;
use OpenSRF::Utils::JSON;
use OpenSRF::AppSession;
return 0;
}
+sub ou_ancestor_setting_value_or_cache {
+ # cache should be specific to setting
+ my ($actor, $org_id, $setting, $cache) = @_;
+
+ if (not exists $cache->{$org_id}) {
+ my $r = $actor->request(
+ 'open-ils.actor.ou_setting.ancestor_default', $org_id, $setting
+ )->gather(1);
+
+ if ($r) {
+ $cache->{$org_id} = $r->{value};
+ } else {
+ $cache->{$org_id} = undef;
+ }
+ }
+ return $cache->{$org_id};
+}
+
my $parser = DateTime::Format::ISO8601->new;
my $log = 'OpenSRF::Utils::Logger';
my @successes;
my $actor = OpenSRF::AppSession->create('open-ils.actor');
+ my $target_when_closed = {};
+ my $target_when_closed_if_at_pickup_lib = {};
+
for my $hold (@$holds) {
try {
#start a transaction if needed
# current target
next if ($c->id eq $hold->current_copy);
- # circ lib is closed
- next if ( grep { ''.$_->org_unit eq ''.$c->circ_lib } @closed );
+ # skip on circ lib is closed IFF we care
+ my $ignore_closing;
+
+ if (''.$hold->pickup_lib eq ''.$c->circ_lib) {
+ $ignore_closing = ou_ancestor_setting_value_or_cache(
+ $actor,
+ ''.$c->circ_lib,
+ 'circ.holds.target_when_closed_if_at_pickup_lib',
+ $target_when_closed_if_at_pickup_lib
+ ) || 0;
+ }
+ if (not $ignore_closing) { # one more chance to find a reason
+ # to ignore OU closedness.
+ $ignore_closing = ou_ancestor_setting_value_or_cache(
+ $actor,
+ ''.$c->circ_lib,
+ 'circ.holds.target_when_closed',
+ $target_when_closed
+ ) || 0;
+ }
+
+# $logger->info(
+# "For hold " . $hold->id . " and copy with circ_lib " .
+# $c->circ_lib . " we " .
+# ($ignore_closing ? "ignore" : "respect")
+# . " closed dates"
+# );
+
+ next if (
+ (not $ignore_closing) and
+ (grep { ''.$_->org_unit eq ''.$c->circ_lib } @closed)
+ );
# target of another hold
next if (action::hold_request
'If unset, the OPAC (only when wrapped in the staff client!) will default to showing you your ten most recent searches on the left side of the results and record details pages. If you actually don''t want to see this feature at all, set this value to zero at the top of your organizational tree.',
'coust', 'description'),
'integer', null)
+,( 'circ.holds.target_when_closed', 'circ',
+ oils_i18n_gettext('circ.holds.target_when_closed',
+ 'Target copies for a hold even if copy''s circ lib is closed',
+ 'coust', 'label'),
+ oils_i18n_gettext('circ.holds.target_when_closed',
+ 'If this setting is true at a given org unit or one of its ancestors, the hold targeter will target copies from this org unit even if the org unit is closed (according to the actor.org_unit.closed_date table).',
+ 'coust', 'description'),
+ 'bool', null)
+,( 'circ.holds.target_when_closed_if_at_pickup_lib', 'circ',
+ oils_i18n_gettext('circ.holds.target_when_closed_if_at_pickup_lib',
+ 'Target copies for a hold even if copy''s circ lib is closed IF the circ lib is the hold''s pickup lib',
+ 'coust', 'label'),
+ oils_i18n_gettext('circ.holds.target_when_closed_if_at_pickup_lib',
+ 'If this setting is true at a given org unit or one of its ancestors, the hold targeter will target copies from this org unit even if the org unit is closed (according to the actor.org_unit.closed_date table) IF AND ONLY IF the copy''s circ lib is the same as the hold''s pickup lib.',
+ 'coust', 'description'),
+ 'bool', null)
+
,( 'opac.staff.jump_to_details_on_single_hit', 'opac',
oils_i18n_gettext('opac.staff.jump_to_details_on_single_hit',
--- /dev/null
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT into config.org_unit_setting_type (name, grp, label, description, datatype) VALUES
+( 'circ.holds.target_when_closed', 'circ',
+ oils_i18n_gettext('circ.holds.target_when_closed',
+ 'Target copies for a hold even if copy''s circ lib is closed',
+ 'coust', 'label'),
+ oils_i18n_gettext('circ.holds.target_when_closed',
+ 'If this setting is true at a given org unit or one of its ancestors, the hold targeter will target copies from this org unit even if the org unit is closed (according to the actor.org_unit.closed_date table).',
+ 'coust', 'description'),
+ 'bool'),
+( 'circ.holds.target_when_closed_if_at_pickup_lib', 'circ',
+ oils_i18n_gettext('circ.holds.target_when_closed_if_at_pickup_lib',
+ 'Target copies for a hold even if copy''s circ lib is closed IF the circ lib is the hold''s pickup lib',
+ 'coust', 'label'),
+ oils_i18n_gettext('circ.holds.target_when_closed_if_at_pickup_lib',
+ 'If this setting is true at a given org unit or one of its ancestors, the hold targeter will target copies from this org unit even if the org unit is closed (according to the actor.org_unit.closed_date table) IF AND ONLY IF the copy''s circ lib is the same as the hold''s pickup lib.',
+ 'coust', 'description'),
+ 'bool')
+;
+
+COMMIT;