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

(-)a/C4/ImportBatch.pm (-4 / +25 lines)
Lines 1606-1611 sub _create_import_record { Link Here
1606
    return $import_record_id;
1606
    return $import_record_id;
1607
}
1607
}
1608
1608
1609
sub _get_import_record_timestamp {
1610
    my ( $marc_record ) = @_;
1611
    my $upload_timestamp = DateTime->now();
1612
1613
    # Attempt to parse the 005 timestamp. This is a bit weird because we have to parse the
1614
    # tenth-of-a-second ourselves.
1615
    my $f005 = $marc_record->field('005');
1616
    if ($f005 && $f005->data =~ /(\d{8}\d{6})\.(\d)/ ) {
1617
    my $parser = DateTime::Format::Strptime->new( pattern => '%Y%m%d%H%M%S' );
1618
    my $parsed_timestamp = $parser->parse_datetime($1);
1619
1620
    # We still check for success because we only did enough validation above to extract the
1621
    # tenth-of-a-second; the timestamp could still be some nonsense like the 50th of Jantober.
1622
    if ( $parsed_timestamp ) {
1623
            $parsed_timestamp->set_nanosecond( $2 * 100_000_000 );
1624
            $upload_timestamp = $parsed_timestamp;
1625
        }
1626
    }
1627
1628
    return $upload_timestamp;
1629
}
1630
1631
1609
sub _update_import_record_marc {
1632
sub _update_import_record_marc {
1610
    my ($import_record_id, $marc_record, $marc_type) = @_;
1633
    my ($import_record_id, $marc_record, $marc_type) = @_;
1611
1634
Lines 1654-1664 sub _update_biblio_fields { Link Here
1654
1677
1655
    my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record);
1678
    my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record);
1656
    my $dbh = C4::Context->dbh;
1679
    my $dbh = C4::Context->dbh;
1657
    # FIXME no controlnumber, originalsource
1680
    # FIXME no originalsource
1658
    # FIXME 2 - should regularize normalization of ISBN wherever it is done
1681
    # FIXME 2 - should regularize normalization of ISBN wherever it is done
1659
    $isbn =~ s/\(.*$//;
1682
    $isbn = C4::Koha::GetNormalizedISBN($isbn);
1660
    $isbn =~ tr/ -_//;
1661
    $isbn = uc $isbn;
1662
    my $sth = $dbh->prepare("UPDATE import_biblios SET title = ?, author = ?, isbn = ?, issn = ?
1683
    my $sth = $dbh->prepare("UPDATE import_biblios SET title = ?, author = ?, isbn = ?, issn = ?
1663
                             WHERE  import_record_id = ?");
1684
                             WHERE  import_record_id = ?");
1664
    $sth->execute($title, $author, $isbn, $issn, $import_record_id);
1685
    $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 239-246 sub _db_query_get_match_conditions { Link Here
239
    if ( $value =~ /\*/ ) {
240
    if ( $value =~ /\*/ ) {
240
        $value =~ s/\*/%/;
241
        $value =~ s/\*/%/;
241
        return { -like => $value };
242
        return { -like => $value };
243
    } elsif ( $index eq 'isbn' ) {
244
        return C4::Koha::GetNormalizedISBN($value) || $value;
242
    } elsif ( $_batch_db_text_columns->{$index} ) {
245
    } elsif ( $_batch_db_text_columns->{$index} ) {
243
        return map +{ -regexp => '[[:<:]]' . $_ . '[[:>:]]' }, split( /\s+/, $value );
246
        my $stripped_value = $value;
247
248
        $stripped_value =~ s/[^\w]//g;
249
        $stripped_value =~ s/^ +| +$//g;
250
251
        return $value if ( !$stripped_value );
252
253
        return map +{ -regexp => '[[:<:]]' . $_ . '[[:>:]]' }, split( /\s+/, $stripped_value );
244
    } else {
254
    } else {
245
        return $value;
255
        return $value;
246
    }
256
    }
Lines 265-271 sub _batch_db_query_from_terms { Link Here
265
            push @db_terms, $_batch_db_mapping->{$index} => [ -and => _db_query_get_match_conditions( $index, $value ) ];
275
            push @db_terms, $_batch_db_mapping->{$index} => [ -and => _db_query_get_match_conditions( $index, $value ) ];
266
        } else {
276
        } else {
267
            # No such index, we should fail
277
            # No such index, we should fail
268
            return undef;
278
            die("No such index");
269
        }
279
        }
270
    }
280
    }
271
281
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc (-4 / +4 lines)
Lines 49-55 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
49
        },
49
        },
50
        [%- FOREACH batch = editable_batches -%]
50
        [%- FOREACH batch = editable_batches -%]
51
            'batch:[% batch.import_batch_id %]': {
51
            'batch:[% batch.import_batch_id %]': {
52
                name: _("Batch: ") + '[% batch.file_name %]',
52
                name: _("Batch: ") + `[% batch.file_name %]`,
53
                recordtype: 'biblio',
53
                recordtype: 'biblio',
54
                checked: false,
54
                checked: false,
55
            },
55
            },
Lines 339-345 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
339
    var editable_batches = {
339
    var editable_batches = {
340
        [%- FOREACH batch = editable_batches -%]
340
        [%- FOREACH batch = editable_batches -%]
341
            [% batch.import_batch_id %]: {
341
            [% batch.import_batch_id %]: {
342
                'name': '[% batch.file_name %]',
342
                'name': `[% batch.file_name %]`,
343
            },
343
            },
344
        [%- END -%]
344
        [%- END -%]
345
    };
345
    };
Lines 364-370 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
364
364
365
        $.each( target_list, function( i, target ) {
365
        $.each( target_list, function( i, target ) {
366
            var $new_target = $(
366
            var $new_target = $(
367
                '<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>'
367
                '<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>`
368
            );
368
            );
369
369
370
            $new_target.find('input').change( function() {
370
            $new_target.find('input').change( function() {
Lines 1433-1439 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
1433
                    $('#loading').hide();
1433
                    $('#loading').hide();
1434
                }
1434
                }
1435
            );
1435
            );
1436
        }; );
1436
        } );
1437
1437
1438
        $.each( backends, function( name ) {
1438
        $.each( backends, function( name ) {
1439
            if ( !this.save ) return; // Not a saving backend
1439
            if ( !this.save ) return; // Not a saving backend
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt (-3 / +4 lines)
Lines 302-307 Link Here
302
302
303
<div id="batches-ui" class="ui-modal modal fade" tabindex="-1" role="dialog" aria-labelledby="batches-title" aria-hidden="true">
303
<div id="batches-ui" class="ui-modal modal fade" tabindex="-1" role="dialog" aria-labelledby="batches-title" aria-hidden="true">
304
304
305
<div class="modal-content">
305
<div class="modal-header">
306
<div class="modal-header">
306
    <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
307
    <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
307
    <h3 id="batches-title">Import batch settings</h3>
308
    <h3 id="batches-title">Import batch settings</h3>
Lines 310-317 Link Here
310
<div class="modal-body row-fluid">
311
<div class="modal-body row-fluid">
311
    <div class="span9">
312
    <div class="span9">
312
        <div id="toolbar" class="btn-toolbar">
313
        <div id="toolbar" class="btn-toolbar">
313
            <button class="btn btn-small" type="submit" id="create-batch"><i class="icon-plus"></i> <span>Create new batch...</span></button>
314
            <button class="btn btn-sm" type="submit" id="create-batch"><i class="icon-plus"></i> <span>Create new batch...</span></button>
314
            <button class="btn btn-small" type="submit" id="manage-batches"><i class="icon-list"></i> <span>Manage import batches...</span></button>
315
            <button class="btn btn-sm" type="submit" id="manage-batches"><i class="icon-list"></i> <span>Manage import batches...</span></button>
315
        </div>
316
        </div>
316
        <table id="batches-table">
317
        <table id="batches-table">
317
            <thead>
318
            <thead>
Lines 329-335 Link Here
329
    <div class="span3">
330
    <div class="span3">
330
    </div>
331
    </div>
331
</div>
332
</div>
332
333
<div>
333
</div>
334
</div>
334
335
335
<div id="shortcuts-contents" style="display: none">
336
<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