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;
27 return bless $self, $class;
34 my $barcodes = $self->patron->charged_items(undef, undef, 1);
36 syslog('LOG_INFO', "OILS: RenewalAll for user ".
37 $self->patron->{id} ." and items [@$barcodes]");
39 for my $barcode (@$barcodes) {
40 my $item = $sip->find_item($barcode);
42 if ($item and $item->{patron} and $item->{patron} eq $self->patron->{id}) {
44 my $renew = OpenILS::SIP::Transaction::Renew->new(authtoken => $self->{authtoken});
45 $renew->patron($self->patron);
47 $renew->do_renew; # renew this single item
49 if ($renew->renewal_ok) {
50 push(@{$self->renewed}, $barcode);
53 push(@{$self->unrenewed}, $barcode);
57 syslog('LOG_INFO', "OILS: RenewalAll item " . $item->{id} .
58 " is not checked out to user " . $self->patron->{id} .
59 ". It's checked out to user " . $item->{patron});
61 push(@{$self->unrenewed}, $barcode);
65 syslog('LOG_INFO', "OILS: RenewalAll ".
66 "ok=[@{$self->renewed}]; not-ok=[@{$self->unrenewed}]");