From 0513ffa58e512d149a44a9d4bd4750d182816e48 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 11 Apr 2024 10:40:16 +0000 Subject: [PATCH] Bug 36563: Turn into array only if required Test plan, apply first patch: 1- Visit item search: http://localhost:8081/cgi-bin/koha/catalogue/itemsearch.pl 2- Set "Home library" -> "is not" -> "Centerville". Notice you get items from Centerville. 3- Apply second patch, repeat step 2, notice you now don't get items from Centervile. 4- Test other use cases, like 'is' and 'is not' for multiple choices Signed-off-by: Owen Leonard Signed-off-by: Lucas Gass Signed-off-by: Katrin Fischer (cherry picked from commit eae74ed6d9935ee7247ccd85f9a1d502755ca338) Signed-off-by: Fridolin Somers --- catalogue/itemsearch.pl | 8 +++++++- .../intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl index 7caba9a0c3..1947dc7b6e 100755 --- a/catalogue/itemsearch.pl +++ b/catalogue/itemsearch.pl @@ -130,7 +130,13 @@ if ( defined $format ) { foreach my $p ( qw(homebranch holdingbranch location itype ccode issues datelastborrowed notforloan itemlost withdrawn damaged)) { - if ( my @q = $cgi->multi_param($p . "[]") ) { + + my @q; + @q = $cgi->multi_param( $p . "[]" ); + if ( scalar @q == 0 ) { + @q = $cgi->multi_param($p); + } + if (@q) { if ( $q[0] ne '' ) { my $f = { field => $p, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt index 3bdbb520a5..43bd168f40 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt @@ -480,10 +480,11 @@ type: 'POST', data: function ( d ) { for (i in params) { - if (! d.hasOwnProperty(params[i].name) ) { - d[params[i].name] = []; + if(d[params[i].name]){ + d[params[i].name] = [].concat(d[params[i].name], params[i].value); + }else{ + d[params[i].name] = params[i].value; } - d[params[i].name].push(params[i].value); } d.format = 'json'; d.columns = JSON.stringify( d.columns ); -- 2.39.5