Bug 4935: fix for allowing authorized values to be "unset"
[koha.git] / tools / batchMod.pl
index 84d1ae1..6a702dc 100755 (executable)
@@ -169,7 +169,7 @@ if ($op eq "show"){
     my @contentlist;
     if ($filefh){
         while (my $content=<$filefh>){
-            $content =~ s/[\r\n]*$//g;
+            $content =~ s/[\r\n]*$//;
             push @contentlist, $content if $content;
         }
 
@@ -203,6 +203,9 @@ if ($op eq "show"){
 
         }
     }
+
+    # Flag to tell the template there are valid results, hidden or not
+    if(scalar(@itemnumbers) > 0){ $template->param("itemresults" => 1); }
     # Only display the items if there are no more than 1000
     if (scalar(@itemnumbers) <= 1000) {
         $items_display_hashref=BuildItemsData(@itemnumbers);
@@ -494,7 +497,7 @@ sub UpdateMarcWith {
        my @fields_to=$marcto->field($itemtag);
     foreach my $subfield ($fieldfrom->subfields()){
                foreach my $field_to_update (@fields_to){
-                               $field_to_update->update($$subfield[0]=>$$subfield[1]) if ($$subfield[1]);
+                               $field_to_update->update($$subfield[0]=>$$subfield[1]) if ($$subfield[1] != '' or $$subfield[1] == '0');
                }
     }
   #warn "TO edited:",$marcto->as_formatted;