Bug 11876: (qa-followup) some minor changes
[koha-ffzg.git] / C4 / ImportBatch.pm
index f320c7a..b8d2560 100644 (file)
@@ -58,6 +58,7 @@ BEGIN {
     GetStagedWebserviceBatches
     GetImportBatchRangeDesc
     GetNumberOfNonZ3950ImportBatches
+    GetImportBiblios
     GetImportRecordsRange
        GetItemNumbersFromImportBatch
     
@@ -1017,6 +1018,25 @@ sub GetNumberOfNonZ3950ImportBatches {
     return $count;
 }
 
+=head2 GetImportBiblios
+
+  my $results = GetImportBiblios($importid);
+
+=cut
+
+sub GetImportBiblios {
+    my ($import_record_id) = @_;
+
+    my $dbh = C4::Context->dbh;
+    my $query = "SELECT * FROM import_biblios WHERE import_record_id = ?";
+    return $dbh->selectall_arrayref(
+        $query,
+        { Slice => {} },
+        $import_record_id
+    );
+
+}
+
 =head2 GetImportRecordsRange
 
   my $results = GetImportRecordsRange($batch_id, $offset, $results_per_group);
@@ -1032,11 +1052,14 @@ sub GetImportRecordsRange {
 
     my $dbh = C4::Context->dbh;
 
-    my $order_by =
-      $dbh->quote_identifier( $parameters->{order_by} || 'import_record_id' );
+    my $order_by = $parameters->{order_by} || 'import_record_id';
+    ( $order_by ) = grep( /^$order_by$/, qw( import_record_id title status overlay_status ) ) ? $order_by : 'import_record_id';
+
     my $order_by_direction =
       uc( $parameters->{order_by_direction} ) eq 'DESC' ? 'DESC' : 'ASC';
 
+    $order_by .= " $order_by_direction, authorized_heading" if $order_by eq 'title';
+
     my $query = "SELECT title, author, isbn, issn, authorized_heading, import_records.import_record_id,
                                            record_sequence, status, overlay_status,
                                            matched_biblionumber, matched_authid, record_type
@@ -1444,7 +1467,7 @@ sub _add_biblio_fields {
     my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record);
     my $dbh = C4::Context->dbh;
     # FIXME no controlnumber, originalsource
-    $isbn = C4::Koha::_isbn_cleanup($isbn); # FIXME C4::Koha::_isbn_cleanup should be made public
+    $isbn = C4::Koha::GetNormalizedISBN($isbn);
     my $sth = $dbh->prepare("INSERT INTO import_biblios (import_record_id, title, author, isbn, issn) VALUES (?, ?, ?, ?, ?)");
     $sth->execute($import_record_id, $title, $author, $isbn, $issn);
     $sth->finish();