From 152124fb1bc2886565a6e166cf3550e3e6d1d589 Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Thu, 28 Jul 2022 09:13:09 -0400 Subject: [PATCH] Bug 31253 - Item search in staff interface should call barcodedecode if the search index is a barcode We should run any inputted barcode through barcodedecode before passing it to any subroutines. This was missed during the initial development of bug 26351. Test Plan: 1) Set itemBarcodeInputFilter to "Remove spaces from" 2) Create an item with the barcode "MYTEST" 3) Browse to the staff side advanced search 4) Run a barcode search for "MY TEST" 5) Note no results are round 6) Apply this patch 7) Restart all the things! 8) Repeat your search 9) Note the item was found! Signed-off-by: Michaela Sieber --- catalogue/itemsearch.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl index 72074a8fdf..3afc43e7eb 100755 --- a/catalogue/itemsearch.pl +++ b/catalogue/itemsearch.pl @@ -22,6 +22,7 @@ use CGI; use JSON qw( to_json ); use C4::Auth qw( get_template_and_user ); +use C4::Circulation qw( barcodedecode ); use C4::Output qw( output_with_http_headers output_html_with_http_headers ); use C4::Items qw( SearchItems ); use C4::Koha qw( GetAuthorisedValues ); @@ -50,6 +51,12 @@ if (defined $format and $format eq 'json') { my @f = $cgi->multi_param('f'); my @q = $cgi->multi_param('q'); + + # If index indicates the value is a barocode, we need to preproccess it before searching + for ( my $i = 0; $i < @q; $i++ ) { + $q[$i] = barcodedecode($q[$i]) if $f[$i] eq 'barcode'; + } + push @q, '' if @q == 0; my @op = $cgi->multi_param('op'); my @c = $cgi->multi_param('c'); -- 2.30.2