View | Details | Raw Unified | Return to bug 35604
Collapse All | Expand All

(-)a/Koha/ILL/Request/Workflow/ConfirmAuto.pm (+116 lines)
Line 0 Link Here
1
package Koha::ILL::Request::Workflow::ConfirmAuto;
2
3
# Copyright 2023 PTFS Europe Ltd
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use base qw(Koha::ILL::Request::Workflow);
23
24
use JSON qw( encode_json );
25
use Koha::ILL::Backends;
26
27
=head1 NAME
28
29
Koha::ILL::Request::Workflow::ConfirmAuto - Koha ILL ConfirmAuto Workflow
30
31
=head1 SYNOPSIS
32
33
Object-oriented class that provides the AutoILLBackendPriority confirmation screen
34
35
=head1 DESCRIPTION
36
37
This class provides the ability to verify if it should render the AutoILLBackendPriority
38
confirmation screen and handle the template params accordingly
39
40
=head1 API
41
42
=head2 Class Methods
43
44
=head3 show_confirm_auto
45
46
    my $show_confirm_auto =
47
    Koha::ILL::Request::Workflow::ConfirmAuto->show_confirm_auto($params);
48
49
Given $request, returns true if confirm auto should be shown
50
51
=cut
52
53
sub show_confirm_auto {
54
    my ( $self, $request ) = @_;
55
56
    return
57
58
        # AutoILLBackendPriority is enabled
59
        C4::Context->preference("AutoILLBackendPriority")
60
61
        # Confirm auto has not yet been submitted
62
        && !$self->{metadata}->{confirm_auto_submitted}
63
64
        # The form has been submitted and the backend is able to create the request
65
        && $request->_backend_capability( 'can_create_request', $self->{metadata} );
66
67
}
68
69
=head3 confirm_auto_template_params
70
71
Given $params, returns the template parameters for rendering the confirm auto screen
72
73
=cut
74
75
sub confirm_auto_template_params {
76
    my ( $self, $params ) = @_;
77
78
    $params->{method} = 'confirmautoill' if $self->{ui_context} eq 'staff';
79
    delete $params->{stage}              if $self->{ui_context} eq 'staff';
80
81
    my @backends = $self->get_priority_backends();
82
    return (
83
        whole              => $params,
84
        metadata           => $self->prep_metadata($params),
85
        core_fields        => Koha::ILL::Backend::Standard->_get_core_fields,
86
        auto_backends_json => scalar encode_json( \@backends ),
87
        $self->{ui_context} eq 'opac'
88
        ? (
89
            illrequestsview => 1,
90
            message         => $params->{message},
91
            op              => 'confirmautoill',
92
            )
93
        : ()
94
    );
95
}
96
97
=head3 get_priority_backends
98
99
Returns backends ordered by AutoILLBackendPriority
100
101
=cut
102
103
sub get_priority_backends {
104
    my ( $self, $params ) = @_;
105
106
    my @backends;
107
    my @priority_enabled_backends = split ",", C4::Context->preference('AutoILLBackendPriority');
108
    foreach my $backend (@priority_enabled_backends) {
109
        my $loaded_backend          = Koha::ILL::Request->new->load_backend($backend);
110
        my $availability_check_info = $loaded_backend->_backend->availability_check_info( $self->{metadata} );
111
        push @backends, $availability_check_info if $availability_check_info;
112
    }
113
    return @backends;
114
}
115
116
1;
(-)a/ill/ill-requests.pl (+9 lines)
Lines 31-36 use Koha::ILL::Request; Link Here
31
use Koha::ILL::Batches;
31
use Koha::ILL::Batches;
32
use Koha::ILL::Request::Workflow::Availability;
32
use Koha::ILL::Request::Workflow::Availability;
33
use Koha::ILL::Request::Workflow::TypeDisclaimer;
33
use Koha::ILL::Request::Workflow::TypeDisclaimer;
34
use Koha::ILL::Request::Workflow::ConfirmAuto;
34
use Koha::Libraries;
35
use Koha::Libraries;
35
use Koha::Plugins;
36
use Koha::Plugins;
36
37
Lines 137-142 if ( $backends_available ) { Link Here
137
          Koha::ILL::Request::Workflow::Availability->new( $params, 'staff' );
138
          Koha::ILL::Request::Workflow::Availability->new( $params, 'staff' );
138
        my $type_disclaimer =
139
        my $type_disclaimer =
139
        Koha::ILL::Request::Workflow::TypeDisclaimer->new( $params, 'staff' );
140
        Koha::ILL::Request::Workflow::TypeDisclaimer->new( $params, 'staff' );
141
        my $confirm_auto =
142
        Koha::ILL::Request::Workflow::ConfirmAuto->new( $params, 'staff' );
140
143
141
        # ILLCheckAvailability operation
144
        # ILLCheckAvailability operation
142
        if ($availability->show_availability($request)) {
145
        if ($availability->show_availability($request)) {
Lines 150-155 if ( $backends_available ) { Link Here
150
            $template->param(
153
            $template->param(
151
                $type_disclaimer->type_disclaimer_template_params($params)
154
                $type_disclaimer->type_disclaimer_template_params($params)
152
            );
155
            );
156
        # ConfirmAuto operation
157
        } elsif ( $confirm_auto->show_confirm_auto($request)) {
158
            $op = 'confirmautoill';
159
            $template->param(
160
                $confirm_auto->confirm_auto_template_params($params)
161
            );
153
        # Ready to create ILL request
162
        # Ready to create ILL request
154
        } else {
163
        } else {
155
            my $backend_result = $request->backend_create($params);
164
            my $backend_result = $request->backend_create($params);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt (+48 lines)
Lines 44-49 Link Here
44
            [% WRAPPER breadcrumb_item bc_active= 1 %]
44
            [% WRAPPER breadcrumb_item bc_active= 1 %]
45
                <span>Request type disclaimer</span>
45
                <span>Request type disclaimer</span>
46
            [% END %]
46
            [% END %]
47
        [% ELSIF query_type == 'confirmautoill' %]
48
            [% WRAPPER breadcrumb_item %]
49
                <a href="/cgi-bin/koha/ill/ill-requests.pl">ILL requests</a>
50
            [% END %]
51
            [% WRAPPER breadcrumb_item bc_active= 1 %]
52
                <span>Confirm automatic request</span>
53
            [% END %]
47
        [% ELSE %]
54
        [% ELSE %]
48
            [% WRAPPER breadcrumb_item bc_active= 1 %]
55
            [% WRAPPER breadcrumb_item bc_active= 1 %]
49
                <span>ILL requests</span>
56
                <span>ILL requests</span>
Lines 922-927 Link Here
922
                            </fieldset>
929
                            </fieldset>
923
                        </form>
930
                        </form>
924
                    </div>
931
                    </div>
932
                    [% ELSIF op == 'confirmautoill' %]
933
                    <!-- confirmautoill -->
934
                    <h1>Confirm automatic request</h1>
935
                    <div id="results" class="page-section">
936
                        <form method="post" id="confirmautoill-form">
937
                            <fieldset class="rows">
938
                                <h3>Confirm backend:</h3>
939
                                <p id="autoillbackends"></p>
940
                                <p id="autoillbackend-message" class="text-info"></p>
941
                            </fieldset>
942
                            <fieldset class="action">
943
                                [% FOREACH key IN whole.keys %]
944
                                    [% value = whole.$key %]
945
                                    [% IF key != 'method' && key != 'custom_key' && key != 'custom_value' %]
946
                                        <input type="hidden" name="[% key | html %]" value="[% value | html %]">
947
                                    [% END %]
948
                                [% END %]
949
                                [% custom_keys = whole.custom_key.split('\0') %]
950
                                [% custom_values = whole.custom_value.split('\0') %]
951
                                [% i = 0 %]
952
                                [% FOREACH custom_key IN custom_keys %]
953
                                    <input type="hidden" name="custom_key" value="[% custom_key | html %]">
954
                                    <input type="hidden" name="custom_value" value="[% custom_values.$i | html %]">
955
                                    [% i = i + 1 %]
956
                                [% END %]
957
                                <input type="hidden" name="method" value="create" />
958
                                <input type="hidden" name="stage" value="form">
959
                                <input type="hidden" name="confirm_auto_submitted" value="1">
960
                                <input type="submit" value="Confirm" />
961
                                <a class="cancel" href="ill-requests.pl">Cancel</a>
962
                            </fieldset>
963
                        </form>
964
                    </div>
925
                [% ELSIF op == 'batch_list' || op == 'batch_create' %]
965
                [% ELSIF op == 'batch_list' || op == 'batch_create' %]
926
                    [% INCLUDE 'ill-batch.inc' %]
966
                    [% INCLUDE 'ill-batch.inc' %]
927
                [% ELSE %]
967
                [% ELSE %]
Lines 966-971 Link Here
966
        [% ELSE %]
1006
        [% ELSE %]
967
        var services = [];
1007
        var services = [];
968
        [% END %]
1008
        [% END %]
1009
        [% IF auto_backends_json.length > 0 %]
1010
        var auto_backends = [% auto_backends_json | $raw %];
1011
        [% ELSE %]
1012
        var auto_backends = [];
1013
        [% END %]
969
        [% IF metadata.length > 0 %]
1014
        [% IF metadata.length > 0 %]
970
        var metadata = "[% metadata | $raw %]";
1015
        var metadata = "[% metadata | $raw %]";
971
        [% END %]
1016
        [% END %]
Lines 989-994 Link Here
989
    [% IF (op == 'availability' || op == 'generic_confirm') && Koha.Preference('ILLCheckAvailability') %]
1034
    [% IF (op == 'availability' || op == 'generic_confirm') && Koha.Preference('ILLCheckAvailability') %]
990
        [% Asset.js("js/ill-availability.js") | $raw %]
1035
        [% Asset.js("js/ill-availability.js") | $raw %]
991
    [% END %]
1036
    [% END %]
1037
    [% IF (op == 'confirmautoill' && Koha.Preference('AutoILLBackendPriority')) %]
1038
        [% Asset.js("js/ill-autobackend.js") | $raw %]
1039
    [% END %]
992
    [% IF op == 'availability' && Koha.Preference('ILLCheckAvailability') %]
1040
    [% IF op == 'availability' && Koha.Preference('ILLCheckAvailability') %]
993
        <script>
1041
        <script>
994
            $(document).ready(function() {
1042
            $(document).ready(function() {
(-)a/koha-tmpl/intranet-tmpl/prog/js/ill-autobackend.js (+163 lines)
Line 0 Link Here
1
$(document).ready(function () {
2
    let auto_ill_el = "#confirmautoill-form #autoillbackends";
3
    let auto_ill_message_el = "#confirmautoill-form #autoillbackend-message";
4
5
    confirmAutoInit();
6
    getBackendsAvailability(auto_backends, metadata);
7
8
    /**
9
     * Retrieves the backend availability for a given auto backend and metadata.
10
     *
11
     * @param {Object} auto_backend - The auto backend object.
12
     * @param {string} metadata - The metadata string.
13
     * @return {Promise} A Promise that resolves to the JSON response.
14
     */
15
    async function getBackendAvailability(auto_backend, metadata) {
16
        return $.ajax({
17
            url: auto_backend.endpoint + metadata,
18
            type: "GET",
19
            dataType: "json",
20
            beforeSend: function () {
21
                _addBackendPlaceholderEl(auto_backend.name);
22
                _addBackendOption(auto_backend.name);
23
                _addVerifyingMessage(auto_backend.name);
24
                auto_backend.available = 0;
25
            },
26
            success: function (data) {
27
                _addSuccessMessage(auto_backend.name);
28
                auto_backend.available = 1;
29
            },
30
            error: function (request, textstatus) {
31
                if (textstatus === "timeout") {
32
                    _addErrorMessage(
33
                        auto_backend.name,
34
                        __("Verification timed out.")
35
                    );
36
                } else {
37
                    let message = "Error";
38
                    if (request.hasOwnProperty("responseJSON")) {
39
                        if (request.responseJSON.error) {
40
                            message = request.responseJSON.error;
41
                        } else if (request.responseJSON.errors) {
42
                            message = request.responseJSON.errors
43
                                .map(error => error.message)
44
                                .join(", ");
45
                        }
46
                    }
47
                    _addErrorMessage(auto_backend.name, message);
48
                }
49
            },
50
            timeout: 10000,
51
        });
52
    }
53
54
    /**
55
     * Asynchronously checks the availability of multiple auto backends.
56
     *
57
     * @param {Array} auto_backends - An array of auto backends to check availability for.
58
     * @param {Object} metadata - Additional metadata for the availability check.
59
     * @return {void}
60
     */
61
    function getBackendsAvailability(auto_backends, metadata) {
62
        let promises = [];
63
        for (const auto_backend of auto_backends) {
64
            try {
65
                const prom = getBackendAvailability(auto_backend, metadata);
66
                promises.push(prom);
67
            } catch (e) {
68
                console.log(e);
69
            }
70
        }
71
        Promise.allSettled(promises).then(() => {
72
            let auto_backend = auto_backends.find(backend => backend.available);
73
            if (typeof auto_backend === "undefined") {
74
                _setAutoBackend("Standard");
75
            } else {
76
                _setAutoBackend(auto_backend.name);
77
            }
78
            $('#confirmautoill-form .action input[type="submit"]').prop(
79
                "disabled",
80
                false
81
            );
82
        });
83
        _addBackendPlaceholderEl("Standard");
84
        _addBackendOption("Standard");
85
    }
86
87
    function _addSuccessMessage(auto_backend_name) {
88
        _removeVerifyingMessage(auto_backend_name);
89
        $(auto_ill_el + " > #backend-" + auto_backend_name).append(
90
            '<span class="text-success"><i class="fa-solid fa-check"></i> ' +
91
                __("Available.").format(auto_backend_name) +
92
                "</span>"
93
        );
94
    }
95
96
    function _addErrorMessage(auto_backend_name, message) {
97
        _removeVerifyingMessage(auto_backend_name);
98
        $(auto_ill_el + " > #backend-" + auto_backend_name).append(
99
            '<span class="text-danger"> <i class="fa-solid fa-xmark"></i> ' +
100
                __("Not readily available:").format(auto_backend_name) +
101
                " " +
102
                message +
103
                "</span>"
104
        );
105
    }
106
107
    function _addBackendOption(auto_backend_name) {
108
        $(auto_ill_el + " > #backend-" + auto_backend_name).append(
109
            ' <input type="radio" id="' +
110
                auto_backend_name +
111
                '" name="backend" value="' +
112
                auto_backend_name +
113
                '">' +
114
                ' <label for="' +
115
                auto_backend_name +
116
                '" class="radio">' +
117
                auto_backend_name +
118
                "</label> "
119
        );
120
    }
121
122
    function _addVerifyingMessage(auto_backend_name) {
123
        $(auto_ill_el + " > #backend-" + auto_backend_name).append(
124
            '<span id="verifying-availabilty" class="text-info"><i id="issues-table-load-delay-spinner" class="fa fa-spinner fa-pulse fa-fw"></i> ' +
125
                __("Verifying availability...").format(auto_backend_name) +
126
                "</span>"
127
        );
128
    }
129
    function _removeVerifyingMessage(auto_backend_name) {
130
        $(
131
            auto_ill_el +
132
                " #backend-" +
133
                auto_backend_name +
134
                " #verifying-availabilty"
135
        ).remove();
136
    }
137
138
    function _setAutoBackend(auto_backend_name) {
139
        $(
140
            '#confirmautoill-form #autoillbackends input[id="' +
141
                auto_backend_name +
142
                '"]'
143
        ).prop("checked", true);
144
        $(auto_ill_message_el).html(
145
            __(
146
                "The recommended backend for your request is <strong>%s</strong>."
147
            ).format(auto_backend_name)
148
        );
149
    }
150
151
    function _addBackendPlaceholderEl(auto_backend_name) {
152
        $(auto_ill_el).append('<div id="backend-' + auto_backend_name + '">');
153
    }
154
155
    function confirmAutoInit() {
156
        $('#confirmautoill-form .action input[name="backend"]').remove();
157
        $('#confirmautoill-form .action input[type="submit"]').prop(
158
            "disabled",
159
            true
160
        );
161
        $(auto_ill_message_el).html(__("Fetching backends availability..."));
162
    }
163
});
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt (-1 / +41 lines)
Lines 45-50 Link Here
45
                [% WRAPPER breadcrumb_item bc_active= 1 %]
45
                [% WRAPPER breadcrumb_item bc_active= 1 %]
46
                    <span>Ill request disclaimer</span>
46
                    <span>Ill request disclaimer</span>
47
                [% END %]
47
                [% END %]
48
            [% ELSIF op == 'confirmautoill' %]
49
                [% WRAPPER breadcrumb_item bc_active= 1 %]
50
                    <span>Confirm automatic request</span>
51
                [% END %]
48
            [% END %]
52
            [% END %]
49
        [% ELSE %]
53
        [% ELSE %]
50
            [% WRAPPER breadcrumb_item bc_active= 1 %]
54
            [% WRAPPER breadcrumb_item bc_active= 1 %]
Lines 121-127 Link Here
121
                                <div id="illrequests-create-button" class="dropdown btn-group">
125
                                <div id="illrequests-create-button" class="dropdown btn-group">
122
                                    [% IF Koha.Preference('AutoILLBackendPriority') %]
126
                                    [% IF Koha.Preference('AutoILLBackendPriority') %]
123
                                        <a id="ill-new" class="btn btn-primary" href="/cgi-bin/koha/opac-illrequests.pl?method=create&amp;backend=Standard">
127
                                        <a id="ill-new" class="btn btn-primary" href="/cgi-bin/koha/opac-illrequests.pl?method=create&amp;backend=Standard">
124
                                            <i class="fa fa-plus" aria-hidden="true"></i> Create a new request
128
                                            <i class="fa fa-plus" aria-hidden="true"></i> Create a new auto request
125
                                        </a>
129
                                        </a>
126
                                    [% ELSIF backends.size > 1 %]
130
                                    [% ELSIF backends.size > 1 %]
127
                                        <button class="btn btn-primary dropdown-toggle" type="button" id="ill-backend-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
131
                                        <button class="btn btn-primary dropdown-toggle" type="button" id="ill-backend-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Lines 329-334 Link Here
329
                                    </fieldset>
333
                                    </fieldset>
330
                                </form>
334
                                </form>
331
                            </div>
335
                            </div>
336
                        [% ELSIF op == 'confirmautoill' %]
337
                            <h1>Confirming automatic request</h1>
338
                            <div id="results" class="page-section">
339
                                <form method="post" id="confirmautoill-form">
340
                                    [% INCLUDE 'csrf-token.inc' %]
341
                                    <fieldset class="rows">
342
                                        <p id="autoillbackends"></p>
343
                                        <p id="autoillbackend-message" class="text-info"></p>
344
                                    </fieldset>
345
                                    <fieldset class="action">
346
                                        [% FOREACH key IN whole.keys %]
347
                                            [% value = whole.$key %]
348
                                            [% IF key != 'custom_key' && key != 'custom_value' && key != 'csrf_token' %]
349
                                                <input type="hidden" name="[% key | html %]" value="[% value | html %]">
350
                                            [% END %]
351
                                        [% END %]
352
                                        [% custom_keys = whole.custom_key.split('\0') %]
353
                                        [% custom_values = whole.custom_value.split('\0') %]
354
                                        [% i = 0 %]
355
                                        [% FOREACH custom_key IN custom_keys %]
356
                                            <input type="hidden" name="custom_key" value="[% custom_key | html %]">
357
                                            <input type="hidden" name="custom_value" value="[% custom_values.$i | html %]">
358
                                            [% i = i + 1 %]
359
                                        [% END %]
360
                                        <input type="hidden" name="confirm_auto_submitted" value="1">
361
                                    </fieldset>
362
                                </form>
363
                            </div>
332
                        [% END # / IF op == 'cud-create' %]
364
                        [% END # / IF op == 'cud-create' %]
333
                    </div> <!-- / #illrequests -->
365
                    </div> <!-- / #illrequests -->
334
                [% END # /IF !backends_available %]
366
                [% END # /IF !backends_available %]
Lines 355-360 Link Here
355
        [% ELSE %]
387
        [% ELSE %]
356
            var services = [];
388
            var services = [];
357
        [% END %]
389
        [% END %]
390
        [% IF auto_backends_json.length > 0 %]
391
        var auto_backends = [% auto_backends_json | $raw %];
392
        [% ELSE %]
393
        var auto_backends = [];
394
        [% END %]
358
        [% IF metadata.length > 0 %]
395
        [% IF metadata.length > 0 %]
359
            var metadata = "[% metadata | $raw %]";
396
            var metadata = "[% metadata | $raw %]";
360
        [% END %]
397
        [% END %]
Lines 367-372 Link Here
367
            });
404
            });
368
        </script>
405
        </script>
369
    [% END %]
406
    [% END %]
407
    [% IF op == 'confirmautoill' %]
408
        [% Asset.js("js/ill-autobackend.js") | $raw %]
409
    [% END %]
370
    [% TRY %]
410
    [% TRY %]
371
        [% PROCESS backend_jsinclude %]
411
        [% PROCESS backend_jsinclude %]
372
    [% CATCH %]
412
    [% CATCH %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/ill-autobackend.js (+161 lines)
Line 0 Link Here
1
$(document).ready(function () {
2
    let auto_ill_el = "#confirmautoill-form #autoillbackends";
3
    let auto_ill_message_el = "#confirmautoill-form #autoillbackend-message";
4
5
    confirmAutoInit();
6
    getBackendsAvailability(auto_backends, metadata);
7
8
    /**
9
     * Retrieves the backend availability for a given auto backend and metadata.
10
     *
11
     * @param {Object} auto_backend - The auto backend object.
12
     * @param {string} metadata - The metadata string.
13
     * @return {Promise} A Promise that resolves to the JSON response.
14
     */
15
    async function getBackendAvailability(auto_backend, metadata) {
16
        return $.ajax({
17
            url: auto_backend.endpoint + metadata,
18
            type: "GET",
19
            dataType: "json",
20
            beforeSend: function () {
21
                _addBackendPlaceholderEl(auto_backend.name);
22
                _addBackendOption(auto_backend.name);
23
                _addVerifyingMessage(auto_backend.name);
24
                auto_backend.available = 0;
25
            },
26
            success: function (data) {
27
                _addSuccessMessage(auto_backend.name);
28
                auto_backend.available = 1;
29
            },
30
            error: function (request, textstatus) {
31
                if (textstatus === "timeout") {
32
                    _addErrorMessage(
33
                        auto_backend.name,
34
                        __("Verification timed out.")
35
                    );
36
                } else {
37
                    let message = "Error";
38
                    if (request.hasOwnProperty("responseJSON")) {
39
                        if (request.responseJSON.error) {
40
                            message = request.responseJSON.error;
41
                        } else if (request.responseJSON.errors) {
42
                            message = request.responseJSON.errors
43
                                .map(error => error.message)
44
                                .join(", ");
45
                        }
46
                    }
47
                    _addErrorMessage(auto_backend.name, message);
48
                }
49
            },
50
            timeout: 10000,
51
        });
52
    }
53
54
    /**
55
     * Asynchronously checks the availability of multiple auto backends.
56
     *
57
     * @param {Array} auto_backends - An array of auto backends to check availability for.
58
     * @param {Object} metadata - Additional metadata for the availability check.
59
     * @return {void}
60
     */
61
    function getBackendsAvailability(auto_backends, metadata) {
62
        let promises = [];
63
        for (const auto_backend of auto_backends) {
64
            try {
65
                const prom = getBackendAvailability(auto_backend, metadata);
66
                promises.push(prom);
67
            } catch (e) {
68
                console.log(e);
69
            }
70
        }
71
        Promise.allSettled(promises).then(() => {
72
            let auto_backend = auto_backends.find(backend => backend.available);
73
            if (typeof auto_backend === "undefined") {
74
                _setAutoBackend("Standard");
75
            } else {
76
                _setAutoBackend(auto_backend.name);
77
            }
78
            $('#confirmautoill-form .action input[type="submit"]').prop(
79
                "disabled",
80
                false
81
            );
82
        });
83
        _addBackendPlaceholderEl("Standard");
84
        _addBackendOption("Standard");
85
    }
86
87
    function _addSuccessMessage(auto_backend_name) {
88
        _removeVerifyingMessage(auto_backend_name);
89
        $(auto_ill_el + " > #backend-" + auto_backend_name).append(
90
            '<span class="text-success"><i class="fa-solid fa-check"></i> ' +
91
                __("Available.").format(auto_backend_name) +
92
                "</span>"
93
        );
94
    }
95
96
    function _addErrorMessage(auto_backend_name, message) {
97
        _removeVerifyingMessage(auto_backend_name);
98
        $(auto_ill_el + " > #backend-" + auto_backend_name).append(
99
            '<span class="text-danger"> <i class="fa-solid fa-xmark"></i> ' +
100
                __("Not readily available:").format(auto_backend_name) +
101
                " " +
102
                message +
103
                "</span>"
104
        );
105
    }
106
107
    function _addBackendOption(auto_backend_name) {
108
        $(auto_ill_el + " > #backend-" + auto_backend_name).append(
109
            ' <input type="radio" id="' +
110
                auto_backend_name +
111
                '" name="backend" value="' +
112
                auto_backend_name +
113
                '">' +
114
                ' <label for="' +
115
                auto_backend_name +
116
                '" class="radio">' +
117
                auto_backend_name +
118
                "</label> "
119
        );
120
    }
121
122
    function _addVerifyingMessage(auto_backend_name) {
123
        $(auto_ill_el + " > #backend-" + auto_backend_name).append(
124
            '<span id="verifying-availabilty" class="text-info"><i id="issues-table-load-delay-spinner" class="fa fa-spinner fa-pulse fa-fw"></i> ' +
125
                __("Verifying availability...").format(auto_backend_name) +
126
                "</span>"
127
        );
128
    }
129
    function _removeVerifyingMessage(auto_backend_name) {
130
        $(
131
            auto_ill_el +
132
                " #backend-" +
133
                auto_backend_name +
134
                " #verifying-availabilty"
135
        ).remove();
136
    }
137
138
    function _setAutoBackend(auto_backend_name) {
139
        $(
140
            '#confirmautoill-form #autoillbackends input[id="' +
141
                auto_backend_name +
142
                '"]'
143
        ).prop("checked", true);
144
        $("#confirmautoill-form").submit();
145
    }
146
147
    function _addBackendPlaceholderEl(auto_backend_name) {
148
        $(auto_ill_el)
149
            .append('<div id="backend-' + auto_backend_name + '">')
150
            .hide();
151
    }
152
153
    function confirmAutoInit() {
154
        $('#confirmautoill-form .action input[name="backend"]').remove();
155
        $(auto_ill_message_el).html(
156
            '<span id="verifying-availabilty" class="text-info"><i id="issues-table-load-delay-spinner" class="fa fa-spinner fa-pulse fa-fw"></i> ' +
157
                __("Placing your request...") +
158
                "</span>"
159
        );
160
    }
161
});
(-)a/opac/opac-illrequests.pl (-1 / +13 lines)
Lines 33-38 use Koha::ILL::Request; Link Here
33
use Koha::Libraries;
33
use Koha::Libraries;
34
use Koha::Patrons;
34
use Koha::Patrons;
35
use Koha::ILL::Request::Workflow::Availability;
35
use Koha::ILL::Request::Workflow::Availability;
36
use Koha::ILL::Request::Workflow::ConfirmAuto;
36
use Koha::ILL::Request::Workflow::TypeDisclaimer;
37
use Koha::ILL::Request::Workflow::TypeDisclaimer;
37
38
38
my $query = CGI->new;
39
my $query = CGI->new;
Lines 124-129 if ( $op eq 'list' ) { Link Here
124
          Koha::ILL::Request::Workflow::Availability->new( $params, 'opac' );
125
          Koha::ILL::Request::Workflow::Availability->new( $params, 'opac' );
125
        my $type_disclaimer =
126
        my $type_disclaimer =
126
          Koha::ILL::Request::Workflow::TypeDisclaimer->new( $params, 'opac' );
127
          Koha::ILL::Request::Workflow::TypeDisclaimer->new( $params, 'opac' );
128
        my $confirm_auto =
129
          Koha::ILL::Request::Workflow::ConfirmAuto->new( $params, 'opac' );
127
130
128
        # ILLCheckAvailability operation
131
        # ILLCheckAvailability operation
129
        if ($availability->show_availability($request)) {
132
        if ($availability->show_availability($request)) {
Lines 145-150 if ( $op eq 'list' ) { Link Here
145
                $template->output, undef,
148
                $template->output, undef,
146
                { force_no_caching => 1 };
149
                { force_no_caching => 1 };
147
            exit;
150
            exit;
151
        # ConfirmAuto operation
152
        } elsif ( $confirm_auto->show_confirm_auto($request)) {
153
            $op = 'confirmautoill';
154
            $template->param(
155
                $confirm_auto->confirm_auto_template_params($params)
156
            );
157
            output_html_with_http_headers $query, $cookie,
158
                $template->output, undef,
159
                { force_no_caching => 1 };
160
            exit;
148
        }
161
        }
149
162
150
        my $patron = Koha::Patrons->find( { borrowernumber => $loggedinuser } );
163
        my $patron = Koha::Patrons->find( { borrowernumber => $loggedinuser } );
151
- 

Return to bug 35604