my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
return $e->event unless $e->allowed('VIEW_USER');
- return $U->storagereq(
+
+ my $bcids = [];
+ if(my $bc = $$search_hash{card}{value}) {
+ $bcids = $e->json_query({
+ select => {ac => ['usr']},
+ from => {ac => {au => {field => 'id', fkey => 'usr'}}},
+ where => {'+ac' => {barcode => {like => "$bc%"}, active => 't'}, '+au' => {deleted => 'f'}}
+ });
+ $bcids = map [ {$_->{usr} ] @$bcids;
+ }
+
+ my $ids = $U->storagereq(
"open-ils.storage.actor.user.crazy_search", $search_hash,
$search_limit, $search_sort, $include_inactive, $e->requestor->ws_ou, $search_depth);
+
+ my %h; # dedup
+ $h{$_} = 1 for (@$bcids, $ids);
+ return [keys %h];
}
}
-
-# ---------------------------------------------------------------------
-# Updates and returns the patron penalties
-# ---------------------------------------------------------------------
-sub update_patron_penalties_nonblock {
- my( $self, %args ) = @_;
- return $self->simplereq(
- 'open-ils.penalty',
- 'open-ils.penalty.patron_penalty.calculate', {background => 1}
- );
-}
-
sub fetch_bill {
my( $self, $billid ) = @_;
$logger->debug("Fetching billing $billid");
return($bill, $evt);
}
-
-
my $ORG_TREE;
sub fetch_org_tree {
my $self = shift;
my $penalties = OpenILS::Utils::Penalty->retrieve_penalties($self->editor, $patronid, $self->circ_lib, $mask);
$penalties = $penalties->{fatal_penalties};
- push(@allevents, OpenILS::Event->new($_)) for (@$penalties, @$patron_events);
+ for my $pen (@$penalties) {
+ my $event = OpenILS::Event->new($pen->name);
+ $event->{desc} = $pen->label;
+ push(@allevents, $event);
+ }
+
+ push(@allevents, OpenILS::Event->new($_)) for (@$patron_events);
}
$logger->info("circulator: permit_patron script returned events: @allevents") if @allevents;
use OpenILS::Utils::PermitHold;
use DateTime;
use DateTime::Format::ISO8601;
+use OpenILS::Penalty;
sub isTrue {
my $v = shift;
my %hoo = map { ( $_->id => $_ ) } actor::org_unit::hours_of_operation->retrieve_all;
- my $penalty = OpenSRF::AppSession->create('open-ils.penalty');
for my $c (@circs) {
try {
$self->method_lookup('open-ils.storage.transaction.commit')->run;
- $penalty->request(
- 'open-ils.penalty.patron_penalty.calculate',
- { patron => $c->usr->to_fieldmapper,
- update => 1,
- background => 1,
- }
- )->gather(1);
+ OpenILS::Utils::Penalty->calculate_penalties(undef, $c->usr, $c->circ_lib);
} catch Error with {
my $e = shift;
sub calculate_penalties {
my($class, $e, $user_id, $context_org) = @_;
+ my $rollback = 0;
+ unless($e) {
+ $e = new_editor(xact =>1);
+ $rollback = 1;
+ }
+
my $penalties = $e->json_query({from => ['actor.calculate_system_penalties',$user_id, $context_org]});
for my $pen_obj (@$penalties) {
}
}
+ $e->rollback if $rollback;
return undef;
}
if($p->standing_penalty->block_list) {
for my $m (@fatal_mask) {
if($p->standing_penalty->block_list =~ /$m/) {
- push(@fatal, $p->standing_penalty->name);
+ push(@fatal, $p->standing_penalty);
$pushed = 1;
last;
}
}
}
- push(@info, $p->standing_penalty->name) unless $pushed;
+ push(@info, $p->standing_penalty) unless $pushed;
}
return {fatal_penalties => \@fatal, info_penalties => \@info};