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

(-)a/tools/batchMod.pl (-32 / +12 lines)
Lines 262-289 if ($op eq "show"){ Link Here
262
        if ($filecontent eq 'barcode_file') {
262
        if ($filecontent eq 'barcode_file') {
263
            @contentlist = grep /\S/, ( map { split /[$split_chars]/ } @contentlist );
263
            @contentlist = grep /\S/, ( map { split /[$split_chars]/ } @contentlist );
264
            @contentlist = uniq @contentlist;
264
            @contentlist = uniq @contentlist;
265
            my @existing_items = @{ Koha::Items->search({ barcode => \@contentlist })->unblessed };
265
            # Note: adding lc for case insensitivity
266
            @existing_items = map {
266
            my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@contentlist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed };
267
                my $barcode = $_;
267
            my @barcodes = grep { exists $itemdata{lc $_} } @contentlist;
268
                grep { $_->{barcode} eq $barcode ? $_ : () } @existing_items
268
            @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @contentlist;
269
            } @contentlist;
269
            @notfoundbarcodes = grep { !exists $itemdata{lc $_} } @contentlist;
270
            @itemnumbers = map { $_->{itemnumber} } @existing_items;
271
            my @barcodes = map { $_->{barcode}    } @existing_items;
272
            # to avoid problems with case sensitivity
273
            my %exists = map { lc($_) => 1 } @barcodes;
274
            @contentlist = map { lc($_) } @contentlist;
275
            @notfoundbarcodes = grep { !$exists{$_} } @contentlist;
276
        }
270
        }
277
        elsif ( $filecontent eq 'itemid_file') {
271
        elsif ( $filecontent eq 'itemid_file') {
278
            @contentlist = uniq @contentlist;
272
            @contentlist = uniq @contentlist;
279
            my @existing_items = @{ Koha::Items->search({ itemnumber => \@contentlist })->unblessed };
273
            my %itemdata = map { $_->{itemnumber} => 1 } @{ Koha::Items->search({ itemnumber => \@contentlist }, { columns => [ 'itemnumber' ] } )->unblessed };
280
            @existing_items = map {
274
            @itemnumbers = grep { exists $itemdata{$_} } @contentlist;
281
                my $barcode = $_;
275
            @notfounditemnumbers = grep { !exists $itemdata{$_} } @contentlist;
282
                grep { $_->{barcode} eq $barcode ? $_ : () } @existing_items
283
            } @contentlist;
284
            @itemnumbers = map { $_->{itemnumber} } @existing_items;
285
            my %exists = map { $_ => 1 } @itemnumbers;
286
            @notfounditemnumbers = grep { !$exists{$_} } @contentlist;
287
        }
276
        }
288
    } else {
277
    } else {
289
        if (defined $biblionumber){
278
        if (defined $biblionumber){
Lines 295-312 if ($op eq "show"){ Link Here
295
        if ( my $list = $input->param('barcodelist') ) {
284
        if ( my $list = $input->param('barcodelist') ) {
296
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
285
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
297
            @barcodelist = uniq @barcodelist;
286
            @barcodelist = uniq @barcodelist;
298
287
            # Note: adding lc for case insensitivity
299
            my @existing_items = @{ Koha::Items->search({ barcode => \@barcodelist })->unblessed };
288
            my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@barcodelist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed };
300
            @existing_items = map {
289
            @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @barcodelist;
301
                my $barcode = $_;
290
            @notfoundbarcodes = grep { !exists $itemdata{lc $_} } @barcodelist;
302
                grep { $_->{barcode} eq $barcode ? $_ : () } @existing_items
303
            } @barcodelist;
304
            @itemnumbers = map { $_->{itemnumber} } @existing_items;
305
            my @barcodes = map { $_->{barcode}    } @existing_items;
306
            # to avoid problems with case sensitivity
307
            my %exists = map { lc($_) => 1 } @barcodes;
308
            @barcodelist = map { lc($_) } @barcodelist;
309
            @notfoundbarcodes = grep { !$exists{$_} } @barcodelist;
310
        }
291
        }
311
    }
292
    }
312
293
313
- 

Return to bug 23800