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

(-)a/C4/ImportBatch.pm (-3 / +5 lines)
Lines 42-48 use Koha::SearchEngine::Indexer; Link Here
42
use Koha::Plugins::Handler;
42
use Koha::Plugins::Handler;
43
use Koha::Logger;
43
use Koha::Logger;
44
use List::MoreUtils qw( uniq any );
44
use List::MoreUtils qw( uniq any );
45
use Array::Utils qw( array_minus );
45
use Array::Utils    qw( array_minus );
46
46
47
our ( @ISA, @EXPORT_OK );
47
our ( @ISA, @EXPORT_OK );
48
48
Lines 1287-1293 Returns an array of imported item branches. Link Here
1287
=cut
1287
=cut
1288
1288
1289
sub GetImportItemsBranches {
1289
sub GetImportItemsBranches {
1290
    my ( $batch_id ) = @_;
1290
    my ($batch_id) = @_;
1291
1291
1292
    my $dbh   = C4::Context->dbh;
1292
    my $dbh   = C4::Context->dbh;
1293
    my $query = "SELECT import_items_id, import_items.marcxml, encoding
1293
    my $query = "SELECT import_items_id, import_items.marcxml, encoding
Lines 1303-1310 sub GetImportItemsBranches { Link Here
1303
    my @branch;
1303
    my @branch;
1304
    my ( $homebranchfield,    $homebranchsubfield )    = GetMarcFromKohaField('items.homebranch');
1304
    my ( $homebranchfield,    $homebranchsubfield )    = GetMarcFromKohaField('items.homebranch');
1305
    my ( $holdingbranchfield, $holdingbranchsubfield ) = GetMarcFromKohaField('items.holdingbranch');
1305
    my ( $holdingbranchfield, $holdingbranchsubfield ) = GetMarcFromKohaField('items.holdingbranch');
1306
1306
    foreach my $row (@$results) {
1307
    foreach my $row (@$results) {
1307
        my $item_marc    = MARC::Record->new_from_xml( StripNonXmlChars( $row->{'marcxml'} ), 'UTF-8', $row->{'encoding'} );
1308
        my $item_marc =
1309
            MARC::Record->new_from_xml( StripNonXmlChars( $row->{'marcxml'} ), 'UTF-8', $row->{'encoding'} );
1308
        push @branch, $item_marc->subfield( $homebranchfield,    $homebranchsubfield );
1310
        push @branch, $item_marc->subfield( $homebranchfield,    $homebranchsubfield );
1309
        push @branch, $item_marc->subfield( $holdingbranchfield, $holdingbranchsubfield );
1311
        push @branch, $item_marc->subfield( $holdingbranchfield, $holdingbranchsubfield );
1310
    }
1312
    }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt (-5 / +6 lines)
Lines 258-268 Link Here
258
                            <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
258
                            <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
259
                        </fieldset>
259
                        </fieldset>
260
                        [% IF ( missing_branches ) %]
260
                        [% IF ( missing_branches ) %]
261
                            <div class="dialog alert"><span>One and more records contains incorrect library codes which are not part of your installation:</span>
261
                            <div class="dialog alert"
262
                                ><span>One and more records contains incorrect library codes which are not part of your installation:</span>
262
                                <span>
263
                                <span>
263
                                [% FOREACH branche IN branches %]
264
                                    [% FOREACH branche IN branches %]
264
                                    [% branche | html %]
265
                                        [% branche | html %]
265
                                [% END %]
266
                                    [% END %]
266
                                </span>
267
                                </span>
267
                            </div>
268
                            </div>
268
                        [% END %]
269
                        [% END %]
Lines 272-278 Link Here
272
                                <span>
273
                                <span>
273
                                    [% FOREACH title IN titles %]
274
                                    [% FOREACH title IN titles %]
274
                                        [% title | html %]
275
                                        [% title | html %]
275
                                         |
276
                                        |
276
                                    [% END %]
277
                                    [% END %]
277
                                </span>
278
                                </span>
278
                            </div>
279
                            </div>
(-)a/t/db_dependent/ImportBatch.t (-7 / +19 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Test::NoWarnings;
4
use Test::More tests => 23;
5
use Test::More tests => 23;
5
use utf8;
6
use utf8;
6
use File::Basename;
7
use File::Basename;
Lines 274-281 subtest "_batchCommitItems" => sub { Link Here
274
        'Error correctly set when import item has duplicate barcode and action always_add'
275
        'Error correctly set when import item has duplicate barcode and action always_add'
275
    );
276
    );
276
277
277
    $import_item = $builder->build_object({ class => 'Koha::Import::Record::Items', value => {
278
    $import_item = $builder->build_object(
278
        marcxml => q{<?xml version="1.0" encoding="UTF-8"?>
279
        {
280
            class => 'Koha::Import::Record::Items',
281
            value => {
282
                marcxml => q{<?xml version="1.0" encoding="UTF-8"?>
279
<collection
283
<collection
280
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
284
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
281
  xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
285
  xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
Lines 293-306 subtest "_batchCommitItems" => sub { Link Here
293
</record>
297
</record>
294
</collection>
298
</collection>
295
        },
299
        },
296
    }});
300
            }
301
        }
302
    );
297
303
298
    ( $num_items_added, $num_items_replaced, $num_items_errored ) =
304
    ( $num_items_added, $num_items_replaced, $num_items_errored ) =
299
        C4::ImportBatch::_batchCommitItems( $import_item->import_record_id, 32, 'always_add',64 );
305
        C4::ImportBatch::_batchCommitItems( $import_item->import_record_id, 32, 'always_add', 64 );
300
    is( $num_items_errored, 1, "Item with wrong branchcode fails when action always_add" );
306
    is( $num_items_errored, 1, "Item with wrong branchcode fails when action always_add" );
301
    $import_item->discard_changes();
307
    $import_item->discard_changes();
302
    is( $import_item->status, 'error', "Import item marked as error when wrong branchcode detected and action always_add");
308
    is(
303
    is( $import_item->import_error, 'Branch code WBRC missing', 'Error correctly set when import item has a wrong branchcode detected and action always_add' );
309
        $import_item->status, 'error',
310
        "Import item marked as error when wrong branchcode detected and action always_add"
311
    );
312
    is(
313
        $import_item->import_error, 'Branch code WBRC missing',
314
        'Error correctly set when import item has a wrong branchcode detected and action always_add'
315
    );
304
};
316
};
305
317
306
subtest "RecordsFromMarcPlugin" => sub {
318
subtest "RecordsFromMarcPlugin" => sub {
Lines 311-317 subtest "RecordsFromMarcPlugin" => sub { Link Here
311
    if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
323
    if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
312
        print $fh q{
324
        print $fh q{
313
003 = NLAmRIJ
325
003 = NLAmRIJ
314
100,a = 20220520d        u||y0frey50      ba
326
100,a = 20220520d        u||y0frey50      by
315
700,a = Author
327
700,a = Author
316
200,ind2 = 0
328
200,ind2 = 0
317
200,a = Silence in the library
329
200,a = Silence in the library
(-)a/tools/manage-marc-import.pl (-3 / +2 lines)
Lines 37-43 use C4::Labels::Batch; Link Here
37
use Koha::BiblioFrameworks;
37
use Koha::BiblioFrameworks;
38
use Koha::BackgroundJob::MARCImportCommitBatch;
38
use Koha::BackgroundJob::MARCImportCommitBatch;
39
use Koha::BackgroundJob::MARCImportRevertBatch;
39
use Koha::BackgroundJob::MARCImportRevertBatch;
40
use Array::Utils qw( array_minus );
40
use Array::Utils    qw( array_minus );
41
use List::MoreUtils qw( uniq any );
41
use List::MoreUtils qw( uniq any );
42
42
43
use Koha::Logger;
43
use Koha::Logger;
Lines 96-102 if ( $op eq "" ) { Link Here
96
        import_batches_list( $template, $offset, $results_per_page );
96
        import_batches_list( $template, $offset, $results_per_page );
97
    } else {
97
    } else {
98
        my @import_items_branches = GetImportItemsBranches($import_batch_id);
98
        my @import_items_branches = GetImportItemsBranches($import_batch_id);
99
        my @import_items = GetBadBranchesImportItems($import_batch_id);
99
        my @import_items          = GetBadBranchesImportItems($import_batch_id);
100
        my @bad_item_titles;
100
        my @bad_item_titles;
101
        my @missing_branches;
101
        my @missing_branches;
102
        foreach my $item (@import_items) {
102
        foreach my $item (@import_items) {
103
- 

Return to bug 21272