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

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

Return to bug 23800