Bug 22996: Move barcode separators to a preference
This patch makes batchMod.pl and inventory.pl pick the barcode separators from a new pref BarcodeSeparators (instead of hardcoding these separators differently). A few other code locations may be potential candidates for such a change too. Test plan: Test inventory with a few variations of BarcodeSeparators. Test Batch item modification similarly. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
b9c236ecb8
commit
237b86006b
|
|
@ -244,16 +244,18 @@ if ($op eq "show"){
|
|||
my $filecontent = $input->param('filecontent');
|
||||
my ( @notfoundbarcodes, @notfounditemnumbers);
|
||||
|
||||
my @contentlist;
|
||||
my $split_chars = C4::Context->preference('BarcodeSeparators');
|
||||
if ($filefh){
|
||||
binmode $filefh, ':encoding(UTF-8)';
|
||||
my @contentlist;
|
||||
while (my $content=<$filefh>){
|
||||
$content =~ s/[\r\n]*$//;
|
||||
push @contentlist, $content if $content;
|
||||
}
|
||||
|
||||
@contentlist = uniq @contentlist;
|
||||
if ($filecontent eq 'barcode_file') {
|
||||
@contentlist = grep /\S/, ( map { split /[$split_chars]/ } @contentlist );
|
||||
@contentlist = uniq @contentlist;
|
||||
my $existing_items = Koha::Items->search({ barcode => \@contentlist });
|
||||
@itemnumbers = $existing_items->get_column('itemnumber');
|
||||
my %exists = map {lc($_)=>1} $existing_items->get_column('barcode');
|
||||
|
|
@ -264,6 +266,7 @@ if ($op eq "show"){
|
|||
@notfoundbarcodes = grep { !$exists{$_} } @contentlist;
|
||||
}
|
||||
elsif ( $filecontent eq 'itemid_file') {
|
||||
@contentlist = uniq @contentlist;
|
||||
@itemnumbers = Koha::Items->search({ itemnumber => \@contentlist })->get_column('itemnumber');
|
||||
my %exists = map {$_=>1} @itemnumbers;
|
||||
@notfounditemnumbers = grep { !$exists{$_} } @contentlist;
|
||||
|
|
@ -275,8 +278,9 @@ if ($op eq "show"){
|
|||
push @itemnumbers, $itm->{itemnumber};
|
||||
}
|
||||
}
|
||||
if ( my $list=$input->param('barcodelist')){
|
||||
push my @barcodelist, uniq( split(/\s\n/, $list) );
|
||||
if ( my $list = $input->param('barcodelist') ) {
|
||||
my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
|
||||
@barcodelist = uniq @barcodelist;
|
||||
|
||||
my $existing_items = Koha::Items->search({ barcode => \@barcodelist });
|
||||
@itemnumbers = $existing_items->get_column('itemnumber');
|
||||
|
|
|
|||
|
|
@ -166,7 +166,8 @@ if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) {
|
|||
my $lines_read=0;
|
||||
binmode($uploadbarcodes, ":encoding(UTF-8)");
|
||||
while (my $barcode=<$uploadbarcodes>) {
|
||||
push @uploadedbarcodes, grep { /\S/ } split( /[\n\r,;|-]/, $barcode );
|
||||
my $split_chars = C4::Context->preference('BarcodeSeparators');
|
||||
push @uploadedbarcodes, grep { /\S/ } split( /[$split_chars]/, $barcode );
|
||||
}
|
||||
for my $barcode (@uploadedbarcodes) {
|
||||
next unless $barcode;
|
||||
|
|
|
|||
Loading…
Reference in New Issue