# Already issued to current borrower. Ask whether the loan should
# be renewed.
- my ($CanBookBeRenewed) = CanBookBeRenewed(
+ my ($CanBookBeRenewed,$renewerror) = CanBookBeRenewed(
$borrower->{'borrowernumber'},
$item->{'itemnumber'}
);
=head2 CanBookBeRenewed
-$ok = &CanBookBeRenewed($borrowernumber, $itemnumber);
+($ok,$error) = &CanBookBeRenewed($borrowernumber, $itemnumber);
Find out whether a borrowed item may be renewed.
C<$CanBookBeRenewed> returns a true value iff the item may be renewed. The
item must currently be on loan to the specified borrower; renewals
must be allowed for the item's type; and the borrower must not have
-already renewed the loan.
+already renewed the loan. $error will contain the reason the renewal can not proceed
=cut
my $dbh = C4::Context->dbh;
my $renews = 1;
my $renewokay = 0;
+ my $error;
# Look in the issues table for this item, lent to this borrower,
# and not yet returned.
if ( $renews && $renews >= $data1->{'renewals'} ) {
$renewokay = 1;
}
+ else {
+ $error="too_many";
+ }
$sth2->finish;
my ( $resfound, $resrec ) = C4::Reserves::CheckReserves($itemnumber);
if ($resfound) {
$renewokay = 0;
+ $error="on_reserve"
}
}
$sth1->finish;
- return ($renewokay);
+ return ($renewokay,$error);
}
=head2 AddRenewal