[Koha-patches] [PATCH] bug: itemlost message doesn't get shown when item returned

Michael Hafen mdhafen at tech.washk12.org
Tue Dec 23 22:22:33 CET 2008


There are two reasons the message doesn't get shown.  First is that
itemlost isn't checked because the item is returned when it's marked
lost.  The second reason is that ModDateLastSeen sets itemlost to 0.
This patch fixes these two spots.

Also, in FixAccountForLostAndReturned, don't use $borrower.  It's passed
in, might be empty, and is only used in one place.
---
 C4/Circulation.pm |    6 ++++--
 C4/Items.pm       |    2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index d48d4f7..cbf5849 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -1388,6 +1388,8 @@ sub AddReturn {
 			  ($borrower) = C4::Members::GetMemberDetails( $iteminformation->{borrowernumber}, 0 );
         }       
         # fix up the accounts.....
+	# Lost items are returned, so itemlost won't be set here unless...
+	$iteminformation->{'itemlost'} = GetItem( $iteminformation->{'itemnumber'} )->{'itemlost'};
         if ( $iteminformation->{'itemlost'} ) {
             $messages->{'WasLost'} = 1;
         }
@@ -1669,9 +1671,9 @@ sub FixAccountForLostAndReturned {
 		$usth = $dbh->prepare("INSERT INTO accountoffsets
 			(borrowernumber, accountno, offsetaccount,  offsetamount)
 			VALUES (?,?,?,?)");
-		$usth->execute($borrower->{'borrowernumber'},$data->{'accountno'},$nextaccntno,$offset);
+		$usth->execute($data->{'borrowernumber'},$data->{'accountno'},$nextaccntno,$offset);
 		$usth->finish;
-        ModItem({ paidfor => '' }, undef, $itm);
+        ModItem({ paidfor => '', itemlost => 0 }, undef, $itm);
 	}
 	$sth->finish;
 	return;
diff --git a/C4/Items.pm b/C4/Items.pm
index 3aef697..227bd61 100644
--- a/C4/Items.pm
+++ b/C4/Items.pm
@@ -536,7 +536,7 @@ sub ModDateLastSeen {
     my ($itemnumber) = @_;
     
     my $today = C4::Dates->new();    
-    ModItem({ itemlost => 0, datelastseen => $today->output("iso") }, undef, $itemnumber);
+    ModItem({ datelastseen => $today->output("iso") }, undef, $itemnumber);
 }
 
 =head2 DelItem
-- 
1.5.6.3




More information about the Koha-patches mailing list