if ( $modified ) {
eval {
if ( my $item = ModItemFromMarc( $localmarcitem, $itemdata->{biblionumber}, $itemnumber ) ) {
- LostItem($itemnumber) if $item->{itemlost} and not $itemdata->{itemlost};
+ LostItem($itemnumber, 'batchmod') if $item->{itemlost} and not $itemdata->{itemlost};
}
};
}
if ($op eq "show"){
my $filefh = $input->upload('uploadfile');
my $filecontent = $input->param('filecontent');
- my @notfoundbarcodes;
+ my ( @notfoundbarcodes, @notfounditemnumbers);
my @contentlist;
if ($filefh){
+ binmode $filefh, ':encoding(UTF-8)';
while (my $content=<$filefh>){
$content =~ s/[\r\n]*$//;
push @contentlist, $content if $content;
@contentlist = uniq @contentlist;
if ($filecontent eq 'barcode_file') {
- foreach my $barcode (@contentlist) {
-
- my $itemnumber = GetItemnumberFromBarcode($barcode);
- if ($itemnumber) {
- push @itemnumbers,$itemnumber;
- } else {
- push @notfoundbarcodes, $barcode;
- }
- }
+ my $existing_items = Koha::Items->search({ itemnumber => \@contentlist });
+ @itemnumbers = $existing_items->get_column('itemnumber');
+ my %exists = map {$_=>1} @{$existing_items->get_column('barcode')};
+ @notfoundbarcodes = grep { !$exists{$_} } @contentlist;
}
elsif ( $filecontent eq 'itemid_file') {
- @itemnumbers = @contentlist;
+ @itemnumbers = Koha::Items->search({ itemnumber => \@contentlist })->get_column('itemnumber');
+ my %exists = map {$_=>1} @itemnumbers;
+ @notfounditemnumbers = grep { !$exists{$_} } @contentlist;
}
} else {
if (defined $biblionumber){
if ( my $list=$input->param('barcodelist')){
push my @barcodelist, uniq( split(/\s\n/, $list) );
- foreach my $barcode (@barcodelist) {
-
- my $itemnumber = GetItemnumberFromBarcode($barcode);
- if ($itemnumber) {
- push @itemnumbers,$itemnumber;
- } else {
- push @notfoundbarcodes, $barcode;
- }
- }
-
+ my $existing_items = Koha::Items->search({ barcode => \@barcodelist });
+ @itemnumbers = $existing_items->get_column('itemnumber');
+ my @barcodes = $existing_items->get_column('barcode');
+ my %exists = map {$_=>1} @barcodes;
+ @notfoundbarcodes = grep { !$exists{$_} } @barcodelist;
}
}
my $subfieldsToAllowForBatchmod = C4::Context->preference('SubfieldsToAllowForRestrictedBatchmod');
my $allowAllSubfields = (
not defined $subfieldsToAllowForBatchmod
- or $subfieldsToAllowForBatchmod == q||
+ or $subfieldsToAllowForBatchmod eq q||
) ? 1 : 0;
my @subfieldsToAllow = split(/ /, $subfieldsToAllowForBatchmod);
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
- $template->param(item => \@loop_data);
- if (@notfoundbarcodes) {
- my @notfoundbarcodesloop = map{{barcode=>$_}}@notfoundbarcodes;
- $template->param(notfoundbarcodes => \@notfoundbarcodesloop);
- }
+ $template->param(
+ item => \@loop_data,
+ notfoundbarcodes => \@notfoundbarcodes,
+ notfounditemnumbers => \@notfounditemnumbers
+ );
$nextop="action"
} # -- End action="show"