Koha/C4/SIP/ILS/Transaction/RenewAll.pm
Henri-Damien LAURENT 4271bbb738 Modifying Members : Add Mod and GetMember
This update the way Member is added and editing so that import and Edition
 could be best automatized
GetMember evolves and allow ppl to serach on a hash of data

Adding SQLHelper A new package to deal with INSERT UPDATE and SELECT

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
2009-09-30 11:29:23 +02:00

64 lines
1.3 KiB
Perl

#
# RenewAll: class to manage status of "Renew All" transaction
package ILS::Transaction::RenewAll;
use strict;
use warnings;
use Sys::Syslog qw(syslog);
use ILS::Item;
use ILS::Transaction::Renew;
use C4::Members; # GetMember
our @ISA = qw(ILS::Transaction::Renew);
my %fields = (
renewed => [],
unrenewed => [],
);
sub new {
my $class = shift;
my $self = $class->SUPER::new();
my $element;
foreach $element (keys %fields) {
$self->{_permitted}->{$element} = $fields{$element};
}
@{$self}{keys %fields} = values %fields;
return bless $self, $class;
}
sub do_renew_all {
my $self = shift;
my $patron = $self->{patron}; # SIP's patron
my $borrower = GetMember('cardnumber'=>$patron->id); # Koha's patron
my $all_ok = 1;
foreach my $itemx (@{$patron->{items}}) {
my $item_id = $itemx->{barcode};
my $item = new ILS::Item $item_id;
if (!defined($item)) {
syslog("LOG_WARNING",
"renew_all: Invalid item id '%s' associated with patron '%s'",
$item_id, $patron->id);
$all_ok = 0;
next;
}
$self->{item} = $item;
$self->do_renew_for($borrower);
if ($self->ok) {
$item->{due_date} = $self->{due};
push @{$self->renewed }, $item_id;
} else {
push @{$self->unrenewed}, $item_id;
}
}
$self->ok($all_ok);
return $self;
}
1;