From 5cb865b87e1bec38c3e8906c172f013e71c21fff Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 25 Jan 2017 16:57:10 +0000 Subject: [PATCH] Bug 17996 - longoverdue.pl should not set 'datereturned' when --mark-returned option is used When longoverdue.pl returns items, it sets old_issues.returndate to the current date. This means that when staff look at the borrowers' circulation history, they see a returndate displayed, which is confusing. We don't lose information by not setting old_issues.returndate, because items.itemlost_on will contain the date that the item was lost. Test Plan: 1) Apply this patch 2) Mark an item lost using longoverdue.pl with --mark-returned 3) Note the item's old_issues line does not have a returndate --- C4/Circulation.pm | 11 +++++++---- misc/cronjobs/longoverdue.pl | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 0230429..03c0215 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2132,7 +2132,9 @@ routine in C. =cut sub MarkIssueReturned { - my ( $borrowernumber, $itemnumber, $dropbox_branch, $returndate, $privacy ) = @_; + my ( $borrowernumber, $itemnumber, $dropbox_branch, $returndate, $privacy, $set_returndate ) = @_; + + $set_returndate //= 1; my $anonymouspatron; if ( $privacy == 2 ) { @@ -2162,7 +2164,7 @@ sub MarkIssueReturned { push @bind, $borrowernumber, $itemnumber; # FIXME transaction my $sth_upd = $dbh->prepare($query); - $sth_upd->execute(@bind); + $sth_upd->execute(@bind) if $set_returndate; my $sth_copy = $dbh->prepare('INSERT INTO old_issues SELECT * FROM issues WHERE borrowernumber = ? AND itemnumber = ?'); @@ -3643,7 +3645,7 @@ sub ReturnLostItem{ sub LostItem{ - my ($itemnumber, $mark_returned) = @_; + my ($itemnumber, $mark_returned, $set_returndate) = @_; my $dbh = C4::Context->dbh(); my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title @@ -3668,7 +3670,8 @@ sub LostItem{ #warn " $issues->{'borrowernumber'} / $itemnumber "; } - MarkIssueReturned($borrowernumber,$itemnumber,undef,undef,$borrower->{'privacy'}) if $mark_returned; + MarkIssueReturned( $borrowernumber, $itemnumber, undef, undef, $borrower->{'privacy'}, $set_returndate ) + if $mark_returned; } } diff --git a/misc/cronjobs/longoverdue.pl b/misc/cronjobs/longoverdue.pl index a0907a2..9780163 100755 --- a/misc/cronjobs/longoverdue.pl +++ b/misc/cronjobs/longoverdue.pl @@ -308,7 +308,8 @@ foreach my $startrange (sort keys %$lost) { printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose); if($confirm) { ModItem({ itemlost => $lostvalue }, $row->{'biblionumber'}, $row->{'itemnumber'}); - LostItem($row->{'itemnumber'}, $mark_returned) if( $charge && $charge eq $lostvalue); + + LostItem( $row->{'itemnumber'}, $mark_returned, 0 ) if ( $charge && $charge eq $lostvalue ); } $count++; } -- 2.1.4