Bug 12363: Add a switch to mark|do not mark items as returned when lost
[koha.git] / cataloguing / additem.pl
index 9387072..a0500a4 100755 (executable)
@@ -164,14 +164,6 @@ sub generate_subfield_form {
            $value = $input->param('barcode');
        }
 
-        # Getting list of subfields to keep when restricted editing is enabled
-        my $subfieldsToAllowForRestrictedEditing = C4::Context->preference('SubfieldsToAllowForRestrictedEditing');
-        my $allowAllSubfields = (
-            not defined $subfieldsToAllowForRestrictedEditing
-              or $subfieldsToAllowForRestrictedEditing == q||
-        ) ? 1 : 0;
-        my @subfieldsToAllow = split(/ /, $subfieldsToAllowForRestrictedEditing);
-
         if ( $subfieldlib->{authorised_value} ) {
             my @authorised_values;
             my %authorised_lib;
@@ -241,13 +233,6 @@ sub generate_subfield_form {
                     labels   => \%authorised_lib,
                     default  => $value,
                 };
-                # If we're on restricted editing, and our field is not in the list of subfields to allow,
-                # then it is read-only
-                $subfield_data{marc_value}->{readonlyselect} = (
-                    not $allowAllSubfields
-                    and $restrictededition
-                    and !grep { $tag . '$' . $subfieldtag  eq $_ } @subfieldsToAllow
-                ) ? 1: 0;
             }
         }
             # it's a thesaurus / authority field
@@ -333,7 +318,23 @@ sub generate_subfield_form {
                 value       => $value,
             };
         }
-        
+
+        # Getting list of subfields to keep when restricted editing is enabled
+        my $subfieldsToAllowForRestrictedEditing = C4::Context->preference('SubfieldsToAllowForRestrictedEditing');
+        my $allowAllSubfields = (
+            not defined $subfieldsToAllowForRestrictedEditing
+              or $subfieldsToAllowForRestrictedEditing == q||
+        ) ? 1 : 0;
+        my @subfieldsToAllow = split(/ /, $subfieldsToAllowForRestrictedEditing);
+
+        # If we're on restricted editing, and our field is not in the list of subfields to allow,
+        # then it is read-only
+        $subfield_data{marc_value}->{readonly} = (
+            not $allowAllSubfields
+            and $restrictededition
+            and !grep { $tag . '$' . $subfieldtag  eq $_ } @subfieldsToAllow
+        ) ? 1: 0;
+
         return \%subfield_data;
 }
 
@@ -411,7 +412,7 @@ $restrictededition = 0 if ($restrictededition != 0 &&  C4::Context->IsSuperLibra
 $restrictededition = 0 if ($restrictededition != 0 && $frameworkcode eq 'FA' && haspermission($uid, {'editcatalogue' => 'fast_cataloging'}));
 
 my $tagslib = &GetMarcStructure(1,$frameworkcode);
-my $record = GetMarcBiblio($biblionumber);
+my $record = GetMarcBiblio({ biblionumber => $biblionumber });
 my $oldrecord = TransformMarcToKoha($record);
 my $itemrecord;
 my $nextop="additem";
@@ -699,7 +700,7 @@ if ($op eq "additem") {
 
    my $newitemlost = $itemtosave->subfield( $lost_tag, $lost_subfield );
     if (($olditemlost eq '0' or $olditemlost eq '' ) and $newitemlost ge '1'){
-  LostItem($itemnumber,'MARK RETURNED');
+        LostItem($itemnumber);
     }
     $nextop="additem";
 } elsif ($op eq "delinkitem"){
@@ -724,7 +725,7 @@ if ($op eq "additem") {
 #-------------------------------------------------------------------------------
 
 # now, build existiing item list
-my $temp = GetMarcBiblio( $biblionumber );
+my $temp = GetMarcBiblio({ biblionumber => $biblionumber });
 #my @fields = $record->fields();
 
 
@@ -748,7 +749,9 @@ if ( C4::Context->preference('EasyAnalyticalRecords') ) {
     foreach my $hostfield ($temp->field($analyticfield)){
         my $hostbiblionumber = $hostfield->subfield('0');
         if ($hostbiblionumber){
-            my $hostrecord = GetMarcBiblio($hostbiblionumber, 1);
+            my $hostrecord = GetMarcBiblio({
+                biblionumber => $hostbiblionumber,
+                embed_items  => 1 });
             if ($hostrecord) {
                 my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostbiblionumber) );
                 foreach my $hostitem ($hostrecord->field($itemfield)){