View | Details | Raw Unified | Return to bug 18823
Collapse All | Expand All

(-)a/C4/ImportBatch.pm (-4 / +25 lines)
Lines 1608-1613 sub _create_import_record { Link Here
1608
    return $import_record_id;
1608
    return $import_record_id;
1609
}
1609
}
1610
1610
1611
sub _get_import_record_timestamp {
1612
    my ( $marc_record ) = @_;
1613
    my $upload_timestamp = DateTime->now();
1614
1615
    # Attempt to parse the 005 timestamp. This is a bit weird because we have to parse the
1616
    # tenth-of-a-second ourselves.
1617
    my $f005 = $marc_record->field('005');
1618
    if ($f005 && $f005->data =~ /(\d{8}\d{6})\.(\d)/ ) {
1619
    my $parser = DateTime::Format::Strptime->new( pattern => '%Y%m%d%H%M%S' );
1620
    my $parsed_timestamp = $parser->parse_datetime($1);
1621
1622
    # We still check for success because we only did enough validation above to extract the
1623
    # tenth-of-a-second; the timestamp could still be some nonsense like the 50th of Jantober.
1624
    if ( $parsed_timestamp ) {
1625
            $parsed_timestamp->set_nanosecond( $2 * 100_000_000 );
1626
            $upload_timestamp = $parsed_timestamp;
1627
        }
1628
    }
1629
1630
    return $upload_timestamp;
1631
}
1632
1633
1611
sub _update_import_record_marc {
1634
sub _update_import_record_marc {
1612
    my ($import_record_id, $marc_record, $marc_type) = @_;
1635
    my ($import_record_id, $marc_record, $marc_type) = @_;
1613
1636
Lines 1656-1666 sub _update_biblio_fields { Link Here
1656
1679
1657
    my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record);
1680
    my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record);
1658
    my $dbh = C4::Context->dbh;
1681
    my $dbh = C4::Context->dbh;
1659
    # FIXME no controlnumber, originalsource
1682
    # FIXME no originalsource
1660
    # FIXME 2 - should regularize normalization of ISBN wherever it is done
1683
    # FIXME 2 - should regularize normalization of ISBN wherever it is done
1661
    $isbn =~ s/\(.*$//;
1684
    $isbn = C4::Koha::GetNormalizedISBN($isbn);
1662
    $isbn =~ tr/ -_//;
1663
    $isbn = uc $isbn;
1664
    my $sth = $dbh->prepare("UPDATE import_biblios SET title = ?, author = ?, isbn = ?, issn = ?
1685
    my $sth = $dbh->prepare("UPDATE import_biblios SET title = ?, author = ?, isbn = ?, issn = ?
1665
                             WHERE  import_record_id = ?");
1686
                             WHERE  import_record_id = ?");
1666
    $sth->execute($title, $author, $isbn, $issn, $import_record_id);
1687
    $sth->execute($title, $author, $isbn, $issn, $import_record_id);
(-)a/Koha/MetaSearcher.pm (-2 / +12 lines)
Lines 22-27 use Modern::Perl; Link Here
22
use base 'Class::Accessor';
22
use base 'Class::Accessor';
23
23
24
use C4::Charset qw( MarcToUTF8Record );
24
use C4::Charset qw( MarcToUTF8Record );
25
use C4::Koha qw(); # Purely for GetNormalizedISBN
25
use C4::Search qw(); # Purely for new_record_from_zebra
26
use C4::Search qw(); # Purely for new_record_from_zebra
26
use DBIx::Class::ResultClass::HashRefInflator;
27
use DBIx::Class::ResultClass::HashRefInflator;
27
use IO::Select;
28
use IO::Select;
Lines 238-245 sub _db_query_get_match_conditions { Link Here
238
    if ( $value =~ /\*/ ) {
239
    if ( $value =~ /\*/ ) {
239
        $value =~ s/\*/%/;
240
        $value =~ s/\*/%/;
240
        return { -like => $value };
241
        return { -like => $value };
242
    } elsif ( $index eq 'isbn' ) {
243
        return C4::Koha::GetNormalizedISBN($value) || $value;
241
    } elsif ( $_batch_db_text_columns->{$index} ) {
244
    } elsif ( $_batch_db_text_columns->{$index} ) {
242
        return map +{ -regexp => '[[:<:]]' . $_ . '[[:>:]]' }, split( /\s+/, $value );
245
        my $stripped_value = $value;
246
247
        $stripped_value =~ s/[^\w]//g;
248
        $stripped_value =~ s/^ +| +$//g;
249
250
        return $value if ( !$stripped_value );
251
252
        return map +{ -regexp => '[[:<:]]' . $_ . '[[:>:]]' }, split( /\s+/, $stripped_value );
243
    } else {
253
    } else {
244
        return $value;
254
        return $value;
245
    }
255
    }
Lines 264-270 sub _batch_db_query_from_terms { Link Here
264
            push @db_terms, $_batch_db_mapping->{$index} => [ -and => _db_query_get_match_conditions( $index, $value ) ];
274
            push @db_terms, $_batch_db_mapping->{$index} => [ -and => _db_query_get_match_conditions( $index, $value ) ];
265
        } else {
275
        } else {
266
            # No such index, we should fail
276
            # No such index, we should fail
267
            return undef;
277
            die("No such index");
268
        }
278
        }
269
    }
279
    }
270
280
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc (-4 / +4 lines)
Lines 42-48 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
42
        },
42
        },
43
        [%- FOREACH batch = editable_batches -%]
43
        [%- FOREACH batch = editable_batches -%]
44
            'batch:[% batch.import_batch_id %]': {
44
            'batch:[% batch.import_batch_id %]': {
45
                name: _("Batch: ") + '[% batch.file_name %]',
45
                name: _("Batch: ") + `[% batch.file_name %]`,
46
                recordtype: 'biblio',
46
                recordtype: 'biblio',
47
                checked: false,
47
                checked: false,
48
            },
48
            },
Lines 314-320 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
314
    var editable_batches = {
314
    var editable_batches = {
315
        [%- FOREACH batch = editable_batches -%]
315
        [%- FOREACH batch = editable_batches -%]
316
            [% batch.import_batch_id %]: {
316
            [% batch.import_batch_id %]: {
317
                'name': '[% batch.file_name %]',
317
                'name': `[% batch.file_name %]`,
318
            },
318
            },
319
        [%- END -%]
319
        [%- END -%]
320
    };
320
    };
Lines 339-345 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
339
339
340
        $.each( target_list, function( i, target ) {
340
        $.each( target_list, function( i, target ) {
341
            var $new_target = $(
341
            var $new_target = $(
342
                '<li><input type="checkbox" class="save-toggle-target" data-target-id="' + target.id + '" id="save-target-' + i + '"' + ( target.checked ? ' checked="checked"' : '' ) + '> <label for="save-target-' + i + '">' + target.label + '</label></li>'
342
                '<li><input type="checkbox" class="save-toggle-target" data-target-id="' + target.id + '" id="save-target-' + i + '"' + ( target.checked ? ' checked="checked"' : '' ) + `> <label for="save-target-` + i + `">` + target.label + `</label></li>`
343
            );
343
            );
344
344
345
            $new_target.find('input').change( function() {
345
            $new_target.find('input').change( function() {
Lines 1408-1414 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
1408
                    $('#loading').hide();
1408
                    $('#loading').hide();
1409
                }
1409
                }
1410
            );
1410
            );
1411
        }; );
1411
        } );
1412
1412
1413
        $.each( backends, function( name ) {
1413
        $.each( backends, function( name ) {
1414
            if ( !this.save ) return; // Not a saving backend
1414
            if ( !this.save ) return; // Not a saving backend
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt (-3 / +4 lines)
Lines 276-281 Link Here
276
276
277
<div id="batches-ui" class="ui-modal modal fade" tabindex="-1" role="dialog" aria-labelledby="batches-title" aria-hidden="true">
277
<div id="batches-ui" class="ui-modal modal fade" tabindex="-1" role="dialog" aria-labelledby="batches-title" aria-hidden="true">
278
278
279
<div class="modal-content">
279
<div class="modal-header">
280
<div class="modal-header">
280
    <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
281
    <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
281
    <h3 id="batches-title">Import batch settings</h3>
282
    <h3 id="batches-title">Import batch settings</h3>
Lines 284-291 Link Here
284
<div class="modal-body row-fluid">
285
<div class="modal-body row-fluid">
285
    <div class="span9">
286
    <div class="span9">
286
        <div id="toolbar" class="btn-toolbar">
287
        <div id="toolbar" class="btn-toolbar">
287
            <button class="btn btn-small" type="submit" id="create-batch"><i class="icon-plus"></i> <span>Create new batch...</span></button>
288
            <button class="btn btn-sm" type="submit" id="create-batch"><i class="icon-plus"></i> <span>Create new batch...</span></button>
288
            <button class="btn btn-small" type="submit" id="manage-batches"><i class="icon-list"></i> <span>Manage import batches...</span></button>
289
            <button class="btn btn-sm" type="submit" id="manage-batches"><i class="icon-list"></i> <span>Manage import batches...</span></button>
289
        </div>
290
        </div>
290
        <table id="batches-table">
291
        <table id="batches-table">
291
            <thead>
292
            <thead>
Lines 303-309 Link Here
303
    <div class="span3">
304
    <div class="span3">
304
    </div>
305
    </div>
305
</div>
306
</div>
306
307
<div>
307
</div>
308
</div>
308
309
309
<div id="shortcuts-contents" style="display: none">
310
<div id="shortcuts-contents" style="display: none">
(-)a/svc/cataloguing/import_batches (-2 / +2 lines)
Lines 195-201 sub create_batch { Link Here
195
195
196
    my $batch_id = AddImportBatch({
196
    my $batch_id = AddImportBatch({
197
        file_name => $batch_name,
197
        file_name => $batch_name,
198
        record_type => 'biblio'
198
        record_type => 'biblio',
199
        import_status => 'staged'
199
    });
200
    });
200
201
201
    $response->param( batch_id => $batch_id );
202
    $response->param( batch_id => $batch_id );
202
- 

Return to bug 18823