Merge remote branch 'colin/QA/bug_4506' into new/enh/bug_4506
[koha_fer] / tools / batchMod.pl
index 7c03812..921c4d6 100755 (executable)
@@ -169,7 +169,7 @@ if ($op eq "show"){
     my @contentlist;
     if ($filefh){
         while (my $content=<$filefh>){
-            chomp $content;
+            $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);
@@ -453,8 +456,11 @@ sub BuildItemsData{
 
             # grab title, author, and ISBN to identify bib that the item
             # belongs to in the display
-                       my $biblio=GetBiblioData($$itemdata{biblionumber});
-            $this_row{bibinfo} = join("\n", @$biblio{qw(title author ISBN)});
+                        my $biblio=GetBiblioData($$itemdata{biblionumber});
+            $this_row{title} = $biblio->{title};
+            $this_row{author} = $biblio->{author};
+            $this_row{isbn} = $biblio->{isbn};
+            $this_row{biblionumber} = $biblio->{biblionumber};
 
                        if (%this_row) {
                                push(@big_array, \%this_row);
@@ -473,7 +479,11 @@ sub BuildItemsData{
                        $row_data{itemnumber} = $row->{itemnumber};
                        #reporting this_row values
                        $row_data{'nomod'} = $row->{'nomod'};
-            $row_data{bibinfo} = $row->{bibinfo};
+      $row_data{bibinfo} = $row->{bibinfo};
+      $row_data{author} = $row->{author};
+      $row_data{title} = $row->{title};
+      $row_data{isbn} = $row->{isbn};
+      $row_data{biblionumber} = $row->{biblionumber};
                        push(@item_value_loop,\%row_data);
                }
                my @header_loop=map { { header_value=> $witness{$_}} } @witnesscodessorted;
@@ -494,7 +504,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;