Bug 10096 - Add a Z39.50 interface for authority searching
[koha.git] / cataloguing / additem.pl
index f2a5ccb..a819019 100755 (executable)
@@ -27,6 +27,7 @@ use C4::Output;
 use C4::Biblio;
 use C4::Items;
 use C4::Context;
+use C4::Circulation;
 use C4::Koha; # XXX subfield_is_koha_internal_p
 use C4::Branch; # XXX subfield_is_koha_internal_p
 use C4::ClassSource;
@@ -401,11 +402,6 @@ if ($op eq "additem") {
         $record = _increment_barcode($record, $frameworkcode);
     }
 
-
-    if (C4::Context->preference('autoBarcode') eq 'incremental') {
-        $record = _increment_barcode($record, $frameworkcode);
-    }
-
     my $addedolditem = TransformMarcToKoha( $dbh, $record );
 
     # If we have to add or add & duplicate, we add the item
@@ -606,6 +602,15 @@ if ($op eq "additem") {
         ModItemFromMarc($itemtosave,$biblionumber,$itemnumber);
         $itemnumber="";
     }
+  my $item = GetItem( $itemnumber );
+    my $olditemlost =  $item->{'itemlost'};
+
+   my ($lost_tag,$lost_subfield) = GetMarcFromKohaField("items.itemlost",'');
+
+   my $newitemlost = $itemtosave->subfield( $lost_tag, $lost_subfield );
+    if (($olditemlost eq '0' or $olditemlost eq '' ) and $newitemlost ge '1'){
+  LostItem($itemnumber,'MARK RETURNED');
+    }
     $nextop="additem";
 } elsif ($op eq "delinkitem"){
     my $analyticfield = '773';