$item->{'itemnumber'},
$branch,
$datedue,
- $issuedate,
+ $issuedate, # here interpreted as the renewal date
);
}
=head2 AddRenewal
-&AddRenewal($borrowernumber, $itemnumber, $branch, [$datedue], [$issuedate]);
+&AddRenewal($borrowernumber, $itemnumber, $branch, [$datedue], [$lastreneweddate]);
Renews a loan.
C<$datedue> can be a C4::Dates object used to set the due date.
-C<$issuedate> can be a iso formatted date to use for the issuedate.
+C<$lastreneweddate> is an optional ISO-formatted date used to set issues.lastreneweddate. If
+this parameter is not supplied, lastreneweddate is set to the current date.
If C<$datedue> is the empty string, C<&AddRenewal> will calculate the due date automatically
from the book's item type.
my $biblio = GetBiblioFromItemNumber($itemnumber) or return undef;
my $branch = (@_) ? shift : $item->{homebranch}; # opac-renew doesn't send branch
my $datedue = shift;
- my $issuedate = shift;
+ my $lastreneweddate = shift;
+
# If the due date wasn't specified, calculate it by adding the
# book's loan length to today's date.
unless ($datedue && $datedue->output('iso')) {
# The question of whether to use item's homebranch calendar is open.
}
+ # $lastreneweddate defaults to today.
+ unless (defined $lastreneweddate) {
+ $lastreneweddate = strftime( "%Y-%m-%d", localtime );
+ }
+
my $dbh = C4::Context->dbh;
# Find the issues record for this book
my $sth =
# Update the issues record to have the new due date, and a new count
# of how many times it has been renewed.
my $renews = $issuedata->{'renewals'} + 1;
- $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = CURRENT_DATE, issuedate = ?
+ $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ?
WHERE borrowernumber=?
AND itemnumber=?"
);
- $sth->execute( $datedue->output('iso'), $renews, $issuedate, $borrowernumber, $itemnumber );
+ $sth->execute( $datedue->output('iso'), $renews, $lastreneweddate, $borrowernumber, $itemnumber );
$sth->finish;
# Update the renewal count on the item, and tell zebra to reindex