1 package OpenILS::SIP::Transaction::RenewAll;
2 use warnings; use strict;
4 use Sys::Syslog qw(syslog);
6 use OpenILS::SIP::Transaction;
7 use OpenILS::SIP::Transaction::Renew;
8 use OpenILS::Application::AppUtils;
9 my $U = 'OpenILS::Application::AppUtils';
11 our @ISA = qw(OpenILS::SIP::Transaction);
20 my $self = $class->SUPER::new(@_);
22 $self->{_permitted}->{$_} = $fields{$_} for keys %fields;
23 @{$self}{keys %fields} = values %fields;
25 return bless $self, $class;
32 my $barcodes = $self->patron->charged_items(undef, undef, 1);
34 syslog('LOG_INFO', "OILS: RenewalAll for user ".
35 $self->patron->{id} ." and items [@$barcodes]");
37 for my $barcode (@$barcodes) {
38 my $item = $sip->find_item($barcode);
40 if ($item and $item->{patron} and $item->{patron} eq $self->patron->{id}) {
42 my $renew = OpenILS::SIP::Transaction::Renew->new(authtoken => $self->{authtoken});
43 $renew->patron($self->patron);
45 $renew->do_renew; # renew this single item
47 if ($renew->renewal_ok) {
48 push(@{$self->renewed}, $barcode);
51 push(@{$self->unrenewed}, $barcode);
55 syslog('LOG_INFO', "OILS: RenewalAll item " . $item->{id} .
56 " is not checked out to user " . $self->patron->{id} .
57 ". It's checked out to user " . $item->{patron});
59 push(@{$self->unrenewed}, $barcode);
63 syslog('LOG_INFO', "OILS: RenewalAll ".
64 "ok=[@{$self->renewed}]; not-ok=[@{$self->unrenewed}]");