]> git.koha-community.org Git - koha.git/blob - C4/SIP/ILS/Transaction/Renew.pm
Merge remote-tracking branch 'origin/new/bug_7613'
[koha.git] / C4 / SIP / ILS / Transaction / Renew.pm
1 #
2 # Status of a Renew Transaction
3 #
4
5 package ILS::Transaction::Renew;
6
7 use warnings;
8 use strict;
9
10 use ILS;
11 use ILS::Transaction;
12
13 use C4::Circulation;
14 use C4::Members;
15
16 our @ISA = qw(ILS::Transaction);
17
18 my %fields = (
19         renewal_ok => 0,
20 );
21
22 sub new {
23         my $class = shift;
24         my $self = $class->SUPER::new();
25
26     foreach my $element (keys %fields) {
27                 $self->{_permitted}->{$element} = $fields{$element};
28         }
29
30         @{$self}{keys %fields} = values %fields;        # overkill?
31         return bless $self, $class;
32 }
33
34 sub do_renew_for  {
35         my $self = shift;
36         my $borrower = shift;
37         my ($renewokay,$renewerror) = CanBookBeRenewed($borrower->{borrowernumber},$self->{item}->{itemnumber});
38         if ($renewokay){
39                 $self->{due} = AddIssue( $borrower, $self->{item}->id, undef, 0 );
40                 $self->renewal_ok(1);
41         } else {
42                 $self->screen_msg(($self->screen_msg || '') . " " . $renewerror);
43                 $self->renewal_ok(0);
44         }
45     $! and warn "do_renew_for error: $!";
46         $self->ok(1) unless $!;
47         return $self;
48 }
49
50 sub do_renew {
51         my $self = shift;
52         my $borrower = GetMember( 'cardnumber'=>$self->{patron}->id);
53         return $self->do_renew_for($borrower);
54 }       
55
56 1;