Koha/C4/SIP/ILS/Transaction/Renew.pm
Colin Campbell 827ef0e83c Bug 8429: Remove unnecessary use of Exporter from SIP/ILS
All the modules in the SIP/ILS tree are objects
The addition of calls to Exporter or hand manipulation of
@ISA added unnecessary bloat
Removed the "self = shift or return" idiom  as it is nonsensical
if the method can only be called via an object.
standardized inheritance via use parent
added a $self = shift in a couple of places where it
was not strictly necessary as its absence seemed to have
misled readers in the past

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Passed-QA-by: Mason James <mtj@kohaaloha.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
2012-11-30 17:50:10 -05:00

60 lines
1.3 KiB
Perl

#
# Status of a Renew Transaction
#
package ILS::Transaction::Renew;
use warnings;
use strict;
use ILS;
use C4::Circulation;
use C4::Members;
use parent qw(ILS::Transaction);
my %fields = (
renewal_ok => 0,
);
sub new {
my $class = shift;
my $self = $class->SUPER::new();
foreach my $element (keys %fields) {
$self->{_permitted}->{$element} = $fields{$element};
}
@{$self}{keys %fields} = values %fields; # overkill?
return bless $self, $class;
}
sub do_renew_for {
my $self = shift;
my $borrower = shift;
my ($renewokay,$renewerror) = CanBookBeRenewed($borrower->{borrowernumber},$self->{item}->{itemnumber});
if ($renewokay){
$self->{due} = undef;
my $due_date = AddIssue( $borrower, $self->{item}->id, undef, 0 );
if ($due_date) {
$self->{due} = $due_date;
}
$self->renewal_ok(1);
} else {
$renewerror=~s/on_reserve/Item unavailable due to outstanding holds/;
$renewerror=~s/too_many/Item has reached maximum renewals/;
$self->screen_msg($renewerror);
$self->renewal_ok(0);
}
$self->ok(1);
return;
}
sub do_renew {
my $self = shift;
my $borrower = GetMember( cardnumber => $self->{patron}->id );
return $self->do_renew_for($borrower);
}
1;