From ccf6b7bd1c96f99ddb352c48e141ba6d5358b5a3 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 13 Nov 2025 14:14:33 +0000 Subject: [PATCH] Bug 41249: Preparation Move confirmauto logic to earlier in controller This is in order to be able to have a have_batch_auto_backends_json which contains all backends that are compatible with both: A) AutoILLBackendPriority sys pref and B) ILL batches --- ill/ill-requests.pl | 23 ++++++++++++++----- .../prog/en/modules/ill/ill-requests.tt | 5 ++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index dec7439dec2..6897a216627 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -66,14 +66,15 @@ my ( $template, $patronnumber, $cookie ) = get_template_and_user( ); # Are we able to actually work? -my $cfg = Koha::ILL::Request::Config->new; -my $backends = $cfg->available_backends; -my $has_branch = $cfg->has_branch; -my $backends_available = ( scalar @{$backends} > 0 ); +my $cfg = Koha::ILL::Request::Config->new; +my $backends = $cfg->available_backends; +my $has_branch = $cfg->has_branch; +my $backends_available = ( scalar @{$backends} > 0 ); +my $have_batch_backends = have_batch_backends($backends); $template->param( backends_available => $backends_available, has_branch => $has_branch, - have_batch => have_batch_backends($backends) + have_batch => $have_batch_backends ); if ( grep( /FreeForm/, @{$backends} ) ) { @@ -97,6 +98,17 @@ if ($backends_available) { $template->param( batch_availability_services => encode_json($batch_availability_services) ); } + # Establish what backends are up for batch autoILL, if enabled + my $confirm_auto = Koha::ILL::Request::Workflow::ConfirmAuto->new( $params, 'staff' ); + my @auto_backends = $confirm_auto->get_priority_backends('staff'); + if ( scalar @auto_backends > 0 && scalar @$have_batch_backends > 0 ) { + my @have_batch_auto_backends = grep { + my $a = $_; + grep { $_ eq $a->{name} } @$have_batch_backends + } @auto_backends; + $template->param( have_batch_auto_backends_json => scalar encode_json( \@have_batch_auto_backends ) ); + } + if ( $op eq 'illview' ) { # View the details of an ILL @@ -137,7 +149,6 @@ if ($backends_available) { my $history_check = Koha::ILL::Request::Workflow::HistoryCheck->new( $params, 'staff' ); my $availability = Koha::ILL::Request::Workflow::Availability->new( $params, 'staff' ); my $type_disclaimer = Koha::ILL::Request::Workflow::TypeDisclaimer->new( $params, 'staff' ); - my $confirm_auto = Koha::ILL::Request::Workflow::ConfirmAuto->new( $params, 'staff' ); # ILLHistoryCheck operation if ( $history_check->show_history_check($request) ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt index 6b82dae88df..5c41b6ab0ea 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt @@ -1145,6 +1145,11 @@ [% ELSE %] var auto_backends = []; [% END %] + [% IF have_batch_auto_backends_json.length > 0 %] + var have_batch_auto_backends = [% have_batch_auto_backends_json | $raw %]; + [% ELSE %] + var have_batch_auto_backends = []; + [% END %] [% IF metadata.length > 0 %] var metadata = "[% metadata | $raw %]"; [% END %] -- 2.39.5