From ffde32e0d71ef80cc42bc8a55b4fc2c4013a6a97 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 3 Mar 2022 10:03:28 +1300 Subject: [PATCH] Bug 8367: (follow-up) Fix pickup delay text on OPAC and other bits Signed-off-by: Emmi Takkinen Signed-off-by: Nick Clemens Signed-off-by: Kelly Signed-off-by: Katrin Fischer Signed-off-by: Kelly Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- Koha/Hold.pm | 4 ++-- admin/smart-rules.pl | 2 +- .../bootstrap/en/modules/opac-reserve.tt | 24 +++++++++++-------- opac/opac-reserve.pl | 8 +++++-- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Koha/Hold.pm b/Koha/Hold.pm index b13892dc6c..9e2f23262c 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -231,8 +231,6 @@ sub set_waiting { my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); - my $new_expiration_date = dt_from_string($self->waitingdate)->clone->add( days => $max_pickup_delay ); - my $rule = Koha::CirculationRules->get_effective_rule({ categorycode => $self->borrower->categorycode, itemtype => $self->item->effective_itemtype, @@ -244,6 +242,8 @@ sub set_waiting { $max_pickup_delay = $rule->rule_value; } + my $new_expiration_date = dt_from_string($self->waitingdate)->clone->add( days => $max_pickup_delay ); + if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype; my $daysmode = Koha::CirculationRules->get_effective_daysmode( diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index 49ae398613..b812e7da0f 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -298,7 +298,7 @@ elsif ($op eq 'add') { my $recall_due_date_interval = $input->param('recall_due_date_interval'); my $recall_overdue_fine = $input->param('recall_overdue_fine'); my $recall_shelf_time = $input->param('recall_shelf_time'); - my $holds_pickup_period = strip_non_numeric($input->param('holds_pickup_period')); + my $holds_pickup_period = strip_non_numeric( scalar $input->param('holds_pickup_period') ); my $rules = { maxissueqty => $maxissueqty, diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index 02674bfc2b..a285057766 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -284,7 +284,7 @@ [% IF pickup_delays %] - + [% END %] @@ -511,13 +511,17 @@ var MSG_EMPTY_END_DATE = _("Hold expiration date should be filled."); function calculate_delay_days(){ - var selected_branch = $("#branch_1").val(); - [% FOREACH branchcode IN pickup_delays.keys %] - var branchcode = "[% branchcode | html %]"; - if ( branchcode == selected_branch ) { - $("#pickup_delay_days").text([% pickup_delays.$branchcode | html %]); - } - [% END %] + $(".branch > select").each(function(){ + var selected_branch = $(this).val(); + var branch_biblionumber = $(this).attr('id'); + var biblionumber = branch_biblionumber.slice( branch_biblionumber.indexOf('_')+1 ); + [% FOREACH branchcode IN pickup_delays.keys %] + var branchcode = "[% branchcode | html %]"; + if ( branchcode == selected_branch ) { + $("#pickup_delay_days_" + biblionumber).text([% pickup_delays.$branchcode | html %]); + } + [% END %] + }); } $(document).ready(function() { @@ -528,8 +532,8 @@ }); calculate_delay_days(); - $("#pickup_delay").show(); - $("#branch_1").change(function(){ + $(".pickup_delay").show(); + $(".branch > select").change(function(){ calculate_delay_days(); }); diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 23c88ef971..b2bff11964 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -626,7 +626,7 @@ if ( ); } -my @branches = Koha::Libraries->search(); +my @branches = Koha::Libraries->search->as_list; my %hold_pickup_delay_by_branch = (); foreach my $branch ( @branches ) { @@ -636,7 +636,11 @@ foreach my $branch ( @branches ) { itemtype => undef, rule_name => 'holds_pickup_period', }); - $hold_pickup_delay_by_branch{$branch->branchcode} = $rule->rule_value if ( $rule and $rule->rule_value ); + if ( $rule and $rule->rule_value ) { + $hold_pickup_delay_by_branch{$branch->branchcode} = $rule->rule_value; + } else { + $hold_pickup_delay_by_branch{$branch->branchcode} = C4::Context->preference('ReservesMaxPickUpDelay'); + } } $template->param( pickup_delays => \%hold_pickup_delay_by_branch ); -- 2.39.5