Skip to content

Commit

Permalink
Bug 37427: Fix club search to display all clubs when search field is …
Browse files Browse the repository at this point in the history
…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

Signed-off-by: Roman Dolny <[email protected]>
Signed-off-by: Lucas Gass <[email protected]>
Signed-off-by: Katrin Fischer <[email protected]>
  • Loading branch information
samlau05 authored and kfischer committed Dec 23, 2024
1 parent 18c3e26 commit 375b3e6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
1 change: 1 addition & 0 deletions koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
<form id="holds_clubsearch" action="request.pl" method="get">
<div class="hint">Enter club ID or partial name:</div>
<input type="text" size="40" id="club" class="focus" name="findclub" autocomplete="off" />
<input type="hidden" name="form_submitted" value="1" />
<input type="submit" class="btn btn-primary" value="Search" />
[% FOREACH biblionumber IN biblionumbers %]
<input type="hidden" name="biblionumber" value="[% biblionumber | html %]"/>
Expand Down
36 changes: 22 additions & 14 deletions reserve/request.pl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ =head1 request.pl
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{};

Expand Down Expand Up @@ -150,22 +151,29 @@ =head1 request.pl
$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 );
}
}

Expand Down

0 comments on commit 375b3e6

Please sign in to comment.