@@ -, +, @@ --- C4/ImportBatch.pm | 29 +++++++++++++++++++--- Koha/MetaSearcher.pm | 14 +++++++++-- .../prog/en/includes/cateditor-ui.inc | 8 +++--- .../prog/en/modules/cataloguing/editor.tt | 7 +++--- svc/cataloguing/import_batches | 3 ++- 5 files changed, 47 insertions(+), 14 deletions(-) --- a/C4/ImportBatch.pm +++ a/C4/ImportBatch.pm @@ -1608,6 +1608,29 @@ sub _create_import_record { return $import_record_id; } +sub _get_import_record_timestamp { + my ( $marc_record ) = @_; + my $upload_timestamp = DateTime->now(); + + # Attempt to parse the 005 timestamp. This is a bit weird because we have to parse the + # tenth-of-a-second ourselves. + my $f005 = $marc_record->field('005'); + if ($f005 && $f005->data =~ /(\d{8}\d{6})\.(\d)/ ) { + my $parser = DateTime::Format::Strptime->new( pattern => '%Y%m%d%H%M%S' ); + my $parsed_timestamp = $parser->parse_datetime($1); + + # We still check for success because we only did enough validation above to extract the + # tenth-of-a-second; the timestamp could still be some nonsense like the 50th of Jantober. + if ( $parsed_timestamp ) { + $parsed_timestamp->set_nanosecond( $2 * 100_000_000 ); + $upload_timestamp = $parsed_timestamp; + } + } + + return $upload_timestamp; +} + + sub _update_import_record_marc { my ($import_record_id, $marc_record, $marc_type) = @_; @@ -1656,11 +1679,9 @@ sub _update_biblio_fields { my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record); my $dbh = C4::Context->dbh; - # FIXME no controlnumber, originalsource + # FIXME no originalsource # FIXME 2 - should regularize normalization of ISBN wherever it is done - $isbn =~ s/\(.*$//; - $isbn =~ tr/ -_//; - $isbn = uc $isbn; + $isbn = C4::Koha::GetNormalizedISBN($isbn); my $sth = $dbh->prepare("UPDATE import_biblios SET title = ?, author = ?, isbn = ?, issn = ? WHERE import_record_id = ?"); $sth->execute($title, $author, $isbn, $issn, $import_record_id); --- a/Koha/MetaSearcher.pm +++ a/Koha/MetaSearcher.pm @@ -22,6 +22,7 @@ use Modern::Perl; use base 'Class::Accessor'; use C4::Charset qw( MarcToUTF8Record ); +use C4::Koha qw(); # Purely for GetNormalizedISBN use C4::Search qw(); # Purely for new_record_from_zebra use DBIx::Class::ResultClass::HashRefInflator; use IO::Select; @@ -238,8 +239,17 @@ sub _db_query_get_match_conditions { if ( $value =~ /\*/ ) { $value =~ s/\*/%/; return { -like => $value }; + } elsif ( $index eq 'isbn' ) { + return C4::Koha::GetNormalizedISBN($value) || $value; } elsif ( $_batch_db_text_columns->{$index} ) { - return map +{ -regexp => '[[:<:]]' . $_ . '[[:>:]]' }, split( /\s+/, $value ); + my $stripped_value = $value; + + $stripped_value =~ s/[^\w]//g; + $stripped_value =~ s/^ +| +$//g; + + return $value if ( !$stripped_value ); + + return map +{ -regexp => '[[:<:]]' . $_ . '[[:>:]]' }, split( /\s+/, $stripped_value ); } else { return $value; } @@ -264,7 +274,7 @@ sub _batch_db_query_from_terms { push @db_terms, $_batch_db_mapping->{$index} => [ -and => _db_query_get_match_conditions( $index, $value ) ]; } else { # No such index, we should fail - return undef; + die("No such index"); } } --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc @@ -42,7 +42,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr }, [%- FOREACH batch = editable_batches -%] 'batch:[% batch.import_batch_id %]': { - name: _("Batch: ") + '[% batch.file_name %]', + name: _("Batch: ") + `[% batch.file_name %]`, recordtype: 'biblio', checked: false, }, @@ -314,7 +314,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr var editable_batches = { [%- FOREACH batch = editable_batches -%] [% batch.import_batch_id %]: { - 'name': '[% batch.file_name %]', + 'name': `[% batch.file_name %]`, }, [%- END -%] }; @@ -339,7 +339,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr $.each( target_list, function( i, target ) { var $new_target = $( - '
  • ' + '
  • ` ); $new_target.find('input').change( function() { @@ -1408,7 +1408,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr $('#loading').hide(); } ); - }; ); + } ); $.each( backends, function( name ) { if ( !this.save ) return; // Not a saving backend --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt @@ -276,6 +276,7 @@