From 9ed869f3eb0e2499b1f84380724f63ba73baf341 Mon Sep 17 00:00:00 2001 From: Sam Lau Date: Mon, 22 Jul 2024 20:04:18 +0000 Subject: [PATCH] Bug 37427: Fix club search to display all clubs when search field is empty, consistent with patron search behavior To test: 1) Create multiple patron clubs 2) Find a bib 3) Click Holds, then Clubs 4) Without entering any text, press the search button 5) Note that the list of clubs is not shown. 6) Apply patch and restart_all 7) Press the search button again, the entire list of clubs should be shown. 8) Ensure original search functionality still works --- .../prog/en/modules/reserve/request.tt | 1 + reserve/request.pl | 36 +++++++++++-------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index 335aa6355f..97a8725f71 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -283,6 +283,7 @@
Enter club ID or partial name:
+ [% FOREACH biblionumber IN biblionumbers %] diff --git a/reserve/request.pl b/reserve/request.pl index 5d0887764d..51dc8d47c2 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -89,6 +89,7 @@ my $messages; my $exceeded_maxreserves; my $exceeded_holds_per_record; my @failed_holds = $input->multi_param('failed_holds'); +my $form_submitted = $input->param('form_submitted'); my $op = $input->param('op') || q{}; @@ -145,22 +146,29 @@ if ($findborrower) { $borrowernumber_hold = $patron->borrowernumber if $patron; } -if($findclub) { - my $club = Koha::Clubs->find( { name => $findclub } ); - if( $club ) { - $club_hold = $club->id; - } else { - my @clubs = Koha::Clubs->search( [ - { name => { like => '%'.$findclub.'%' } }, - { description => { like => '%'.$findclub.'%' } } - ] )->as_list; - if( scalar @clubs == 1 ) { - $club_hold = $clubs[0]->id; - } elsif ( @clubs ) { - $template->param( clubs => \@clubs ); +if ($form_submitted) { + if ($findclub) { + my $club = Koha::Clubs->find( { name => $findclub } ); + if ($club) { + $club_hold = $club->id; } else { - $messageclub = "'$findclub'"; + my @clubs = Koha::Clubs->search( + [ + { name => { like => '%' . $findclub . '%' } }, + { description => { like => '%' . $findclub . '%' } } + ] + )->as_list; + if ( scalar @clubs == 1 ) { + $club_hold = $clubs[0]->id; + } elsif (@clubs) { + $template->param( clubs => \@clubs ); + } else { + $messageclub = "'$findclub'"; + } } + } else { + my @clubs = Koha::Clubs->search()->as_list; + $template->param( clubs => \@clubs ); } } -- 2.39.2