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:
   <staff_url>/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:
   <staff_url>/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
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit bb790bea23)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Pedro Amorim 2025-05-16 11:39:42 +00:00 committed by Paul Derscheid
parent 7d01add921
commit 316b1d37b8
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
2 changed files with 57 additions and 11 deletions

View File

@ -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

View File

@ -45,6 +45,8 @@
<span>Manage request [% request.id_prefix _ request.illrequest_id | html %]</span>
[% ELSIF op == 'confirm' %]
<span>Confirm request [% request.id_prefix _ request.illrequest_id | html %]</span>
[% ELSIF op == 'mark_completed' %]
<span>Complete request request [% request.id_prefix _ request.illrequest_id | html %]</span>
[% ELSIF op == 'delete_confirm' %]
<span>Delete request [% request.id_prefix _ request.illrequest_id | html %]</span>
[% ELSIF op == 'generic_confirm' %]
@ -115,6 +117,29 @@
[% ELSIF op == 'confirm' %]
<h1>Confirm ILL request</h1>
[% PROCESS $whole.template %]
[% ELSIF op == 'mark_completed' %]
<h1>Complete ILL request</h1>
<p>Proceeding with this action will set this request to 'Completed'.</p>
<p>You can select a status alias from the available options:</p>
<p>
[% base_url = "/cgi-bin/koha/ill/ill-requests.pl" %]
[% proceed_url = base_url _ "?method=mark_completed&stage=complete" _ "&illrequest_id=" _ request.illrequest_id %]
<form action="[% proceed_url | url %]" method="get">
<select name="status_alias">
<option value="" selected></option>
[% FOREACH alias IN AuthorisedValues.Get('ILL_STATUS_ALIAS') %]
<option value="[% alias.authorised_value | html %]" > [% alias.lib | html %] </option>
[% END %]
</select>
<input type="hidden" name="method" value="mark_completed">
<input type="hidden" name="stage" value="complete">
<input type="hidden" name="illrequest_id" value="[% request.illrequest_id %]">
<fieldset class="action">
<button type="submit" class="btn btn-sm btn-primary">Complete request</button>
<a class="btn btn-sm btn-default cancel" href="[% base_url | url %]">Cancel</a>
</fieldset>
</form>
</p>
[% ELSIF op == 'cud-cancel' and !whole.error %]
<h1>Cancel a confirmed request</h1>
[% PROCESS $whole.template %]