From da8baebf03e07d19d433bae338a9aefdb345946e Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 22 Apr 2025 17:42:07 +0100 Subject: [PATCH] Bug 9762: (follow-up) Re-instate bug 37868 --- reserve/request.pl | 51 ++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/reserve/request.pl b/reserve/request.pl index 3ec07c9cc97..bf310892733 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -34,7 +34,7 @@ use Date::Calc qw( Date_to_Days ); use C4::Output qw( output_html_with_http_headers ); use C4::Auth qw( get_template_and_user ); use C4::Reserves - qw( RevertWaitingStatus AlterPriority ToggleLowestPriority ToggleSuspend CanBookBeReserved GetMaxPatronHoldsForRecord CanItemBeReserved IsAvailableForItemLevelRequest ); + qw( RevertWaitingStatus AlterPriority ToggleLowestPriority CanBookBeReserved GetMaxPatronHoldsForRecord CanItemBeReserved IsAvailableForItemLevelRequest ); use C4::Items qw( get_hostitemnumbers_of ); use C4::Koha qw( getitemtypeimagelocation ); use C4::Serials qw( CountSubscriptionFromBiblionumber ); @@ -90,7 +90,8 @@ my $warnings; my $messages; my $exceeded_maxreserves; my $exceeded_holds_per_record; -my @failed_holds = $input->multi_param('failed_holds'); +my @failed_holds = $input->multi_param('failed_holds'); +my $form_submitted = $input->param('form_submitted'); my $op = $input->param('op') || q{}; @@ -118,10 +119,15 @@ if ( $op eq 'cud-move' ) { } elsif ( $op eq 'cud-setLowestPriority' ) { my $reserve_id = $input->param('reserve_id'); ToggleLowestPriority($reserve_id); -} elsif ( $op eq 'cud-toggleSuspend' ) { +} elsif ( $op eq 'cud-suspend' ) { my $reserve_id = $input->param('reserve_id'); my $suspend_until = $input->param('suspend_until'); - ToggleSuspend( $reserve_id, $suspend_until ); + my $hold = Koha::Holds->find($reserve_id); + $hold->suspend_hold($suspend_until) if $hold; +} elsif ( $op eq 'cud-unsuspend' ) { + my $reserve_id = $input->param('reserve_id'); + my $hold = Koha::Holds->find($reserve_id); + $hold->resume() if $hold; } elsif ( $op eq 'cud-cancel_bulk' ) { my $cancellation_reason = $input->param("cancellation-reason"); my @hold_ids = split( ',', scalar $input->param("ids") ); @@ -142,24 +148,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.49.0