Bug 20305: Remove warnings from tools scripts
[koha.git] / tools / batch_records_ajax.pl
index bc0fe82..349d858 100755 (executable)
@@ -31,7 +31,7 @@ the records from an import batch.
 
 use Modern::Perl;
 
-use CGI;
+use CGI qw ( -utf8 );
 use JSON qw/ to_json /;
 
 use C4::Context;
@@ -47,10 +47,10 @@ my @sort_columns =
 my $import_batch_id   = $input->param('import_batch_id');
 my $offset            = $input->param('iDisplayStart');
 my $results_per_page  = $input->param('iDisplayLength');
-my $sorting_column    = $sort_columns[ $input->param('iSortCol_0') ];
+my $sorting_column    = $sort_columns[ $input->param('iSortCol_0') // 0 ];
 my $sorting_direction = $input->param('sSortDir_0');
 
-$results_per_page = undef if ( $results_per_page == -1 );
+$results_per_page = undef if $results_per_page && $results_per_page == -1;
 
 binmode STDOUT, ":encoding(UTF-8)";
 print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
@@ -107,6 +107,7 @@ foreach my $record (@$records) {
           || q{},
         score => $#$match > -1 ? $match->[0]->{'score'} : 0,
         match_id => $match_id,
+        diff_url => $match_id ? "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=$import_batch_id&importid=$record->{import_record_id}&id=$match_id" : undef
       };
 }