[Koha-patches] [PATCH] process change to lost status when set from Edit Item screen

Michael Hafen mdhafen at tech.washk12.org
Tue Dec 23 23:03:46 CET 2008


Do the apropriate thing if the itemlost status is change on the Edit
Item screen, as opposed to the lost status being changed on the Item
Information screen.
---
 cataloguing/additem.pl |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl
index f8780c2..c38d292 100755
--- a/cataloguing/additem.pl
+++ b/cataloguing/additem.pl
@@ -59,6 +59,17 @@ sub get_item_from_barcode {
     return($result);
 }
 
+sub get_item_lost_status {
+    my ( $itemnumber ) = @_;
+    my $dbh = C4::Context->dbh;
+    my $result;
+    my $query = "SELECT itemlost from items where itemnumber = ?";
+    my $sth = $dbh->prepare( $query );
+    $sth->execute( $itemnumber );
+    ( $result ) = $sth->fetchrow;
+    return $result;
+}
+
 my $input = new CGI;
 my $dbh = C4::Context->dbh;
 my $error = $input->param('error');
@@ -177,6 +188,19 @@ if ($op eq "additem") {
     if ($exist_itemnumber && $exist_itemnumber != $itemnumber) {
         push @errors,"barcode_not_unique";
     } else {
+        # check if Lost was change.
+        my $exist_lost = get_item_lost_status( $itemnumber );
+        if ( $exist_lost != $addedolditem->{'itemlost'} ) {
+            if ( $exist_lost == 0 && $addedolditem->{'itemlost'} == 1 ) {
+                C4::Accounts::chargelostitem($itemnumber)
+            } elsif ( $exist_lost == 1 && (
+                          $addedolditem->{'itemlost'} == 0 ||
+                          $addedolditem->{'itemlost'} == '' ) ) {
+                # FIXME Should check if the previous borrower lost the item,
+                # and pass their info here instead of an empty hash
+                C4::Circulation::FixAccountForLostAndReturned( $addedolditem, {} );
+            }
+        }
         my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = ModItemFromMarc($itemtosave,$biblionumber,$itemnumber);
     $itemnumber="";
     }
-- 
1.5.6.3




More information about the Koha-patches mailing list