From 7eb4f502785c970d3a8ba2648804804fbed5dc9e Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 16 May 2025 11:39:42 +0000 Subject: [PATCH] Bug 39917: Add new optional 'mark_completed' ILL screen This new 'Mark completed' screen only shows when ILL_STATUS_ALIAS is not empty, i.e. Koha installations that are not using ILL_STATUS_ALIAS will not see any change in their workflow. Backends that don't implement 'mark_completed' are inherently already making use of core 'mark_completed' and will automatically adopt this enhancement. Backends that do implement their own mark_completed don't automatically adopt this enhancement and will not see any change in their workflow. Test plan: 1) Enable ILLModule sys pref 2) Create a new ILL request: /cgi-bin/koha/ill/ill-requests.pl?method=create&backend=Standard 3) Add a type, cardnumber and library. Click 'Create'. 4) You should now be on the manage request screen. Click 'Confirm' and 'Confirm request'. 5) You should be on the manage request screen again. Click 'Mark completed'. The request's status became 'Completed'. 6) Add at least one AV entry to ILL_STATUS_ALIAS av category, visit: /cgi-bin/koha/admin/authorised_values.pl?op=add_form&category=ILL_STATUS_ALIAS 7) Add 'abc_code' to 'Authorized value' and 'abc_description' to 'Description'. Click 'Save'. 8) Repeat steps 2 to 5. Notice that when you 'Mark completed' now, a new screen is shown prompting for a status_alias. 9) Pick a status_alias and save. Notice the 'status' now shows the alias. Sponsored-by: NHS England --- Koha/ILL/Request.pm | 43 ++++++++++++++----- .../prog/en/modules/ill/ill-requests.tt | 25 +++++++++++ 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index 9b151e3924c..fda4d98f38f 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -910,17 +910,38 @@ Mark a request as completed (status = COMP). =cut sub mark_completed { - my ($self) = @_; - $self->status('COMP')->store; - $self->completed( dt_from_string() )->store; - return { - error => 0, - status => '', - message => '', - method => 'mark_completed', - stage => 'commit', - next => 'illview', - }; + my ( $self, $params ) = @_; + + my $stage = $params->{stage}; + + my $status_aliases_exist = Koha::AuthorisedValues->search( { category => 'ILL_STATUS_ALIAS' } )->count; + + if ( ( !$stage || $stage eq 'init' ) && $status_aliases_exist ) { + return { + method => 'mark_completed', + }; + } elsif ( !$stage || $stage eq 'complete' ) { + + $self->status('COMP'); + $self->status_alias( $params->{status_alias} ) if $params->{status_alias}; + $self->completed( dt_from_string() ); + $self->store; + return { + stage => 'commit', + next => 'illview', + }; + } else { + + # Invalid stage, return error. + return { + error => 1, + status => 'unknown_stage', + message => '', + method => 'confirm', + stage => $params->{stage}, + value => {}, + }; + } } =head2 backend_illview 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 26ba077ed94..63974c3f9d1 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 @@ -45,6 +45,8 @@ Manage request [% request.id_prefix _ request.illrequest_id | html %] [% ELSIF op == 'confirm' %] Confirm request [% request.id_prefix _ request.illrequest_id | html %] + [% ELSIF op == 'mark_completed' %] + Complete request request [% request.id_prefix _ request.illrequest_id | html %] [% ELSIF op == 'delete_confirm' %] Delete request [% request.id_prefix _ request.illrequest_id | html %] [% ELSIF op == 'generic_confirm' %] @@ -115,6 +117,29 @@ [% ELSIF op == 'confirm' %]

Confirm ILL request

[% PROCESS $whole.template %] + [% ELSIF op == 'mark_completed' %] +

Complete ILL request

+

Proceeding with this action will set this request to 'Completed'.

+

You can select a status alias from the available options:

+

+ [% base_url = "/cgi-bin/koha/ill/ill-requests.pl" %] + [% proceed_url = base_url _ "?method=mark_completed&stage=complete" _ "&illrequest_id=" _ request.illrequest_id %] +

+ + + + +
+ + Cancel +
+
+

[% ELSIF op == 'cud-cancel' and !whole.error %]

Cancel a confirmed request

[% PROCESS $whole.template %] -- 2.39.5