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

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

Return to bug 23800