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 <michaela.sieber@kit.edu>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Edit: fixed typo in comment
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit d735a5804b)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 41d9b86323)
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
This commit is contained in:
Kyle Hall 2022-07-28 09:13:09 -04:00 committed by Pedro Amorim
parent d024f6a225
commit 6130a7482d

View file

@ -22,6 +22,7 @@ use CGI;
use JSON qw( to_json ); use JSON qw( to_json );
use C4::Auth qw( get_template_and_user ); 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::Output qw( output_with_http_headers output_html_with_http_headers );
use C4::Items qw( SearchItems ); use C4::Items qw( SearchItems );
use C4::Koha qw( GetAuthorisedValues ); use C4::Koha qw( GetAuthorisedValues );
@ -50,6 +51,12 @@ if (defined $format and $format eq 'json') {
my @f = $cgi->multi_param('f'); my @f = $cgi->multi_param('f');
my @q = $cgi->multi_param('q'); my @q = $cgi->multi_param('q');
# If index indicates the value is a barcode, 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; push @q, '' if @q == 0;
my @op = $cgi->multi_param('op'); my @op = $cgi->multi_param('op');
my @c = $cgi->multi_param('c'); my @c = $cgi->multi_param('c');