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

(-)a/ill/ill-requests.pl (-41 / +29 lines)
Lines 27-33 use Koha::Notice::Templates; Link Here
27
use Koha::AuthorisedValues;
27
use Koha::AuthorisedValues;
28
use Koha::Illcomment;
28
use Koha::Illcomment;
29
use Koha::Illrequests;
29
use Koha::Illrequests;
30
use Koha::Illrequest::Availability;
30
use Koha::Illrequest::Workflow::Availability;
31
use Koha::Illrequest::Workflow::TypeDisclaimer;
31
use Koha::Libraries;
32
use Koha::Libraries;
32
use Koha::Token;
33
use Koha::Token;
33
34
Lines 104-158 if ( $backends_available ) { Link Here
104
105
105
106
106
    } elsif ( $op eq 'create' ) {
107
    } elsif ( $op eq 'create' ) {
107
        # We're in the process of creating a request
108
        # Load the ILL backend
108
        my $request = Koha::Illrequest->new->load_backend( $params->{backend} );
109
        my $request = Koha::Illrequest->new->load_backend( $params->{backend} );
109
        # Does this backend enable us to insert an availability stage and should
110
110
        # we? If not, proceed as normal.
111
        # Before request creation operations - Preparation
111
        if (
112
        my $availability =
112
            # If the user has elected to continue with the request despite
113
          Koha::Illrequest::Workflow::Availability->new( $params, 'staff' );
113
            # having viewed availability info, this flag will be set
114
        my $type_disclaimer =
114
            C4::Context->preference("ILLCheckAvailability")
115
          Koha::Illrequest::Workflow::TypeDisclaimer->new( $params, 'staff' );
115
              && !$params->{checked_availability}
116
116
              && $request->_backend_capability( 'should_display_availability', $params )
117
        # ILLCheckAvailability operation
117
        ) {
118
        if ($availability->show_availability($request)) {
118
            # Establish which of the installed availability providers
119
            $op = 'availability';
119
            # can service our metadata
120
            $template->param(
120
            my $availability = Koha::Illrequest::Availability->new($params);
121
                $availability->availability_template_params($params)
121
            my $services = $availability->get_services({
122
            )
122
                ui_context => 'staff'
123
        # ILLModuleDisclaimerByType operation
123
            });
124
        } elsif ( $type_disclaimer->show_type_disclaimer($request, $params)) {
124
            if (scalar @{$services} > 0) {
125
            $op = 'typedisclaimer';
125
                # Modify our method so we use the correct part of the
126
            $template->param(
126
                # template
127
                $type_disclaimer->type_disclaimer_template_params($params)
127
                $op = 'availability';
128
            );
128
                $params->{method} = 'availability';
129
        # Ready to create ILL request
129
                delete $params->{stage};
130
                # Prepare the metadata we're sending them
131
                my $metadata = $availability->prep_metadata($params);
132
                $template->param(
133
                    whole         => $params,
134
                    metadata      => $metadata,
135
                    services_json => scalar encode_json($services),
136
                    services      => $services
137
                );
138
            } else {
139
                # No services can process this metadata, so continue as normal
140
                my $backend_result = $request->backend_create($params);
141
                $template->param(
142
                    whole   => $backend_result,
143
                    request => $request
144
                );
145
                handle_commit_maybe($backend_result, $request);
146
            }
147
        } else {
130
        } else {
148
            my $backend_result = $request->backend_create($params);
131
            my $backend_result = $request->backend_create($params);
132
133
            # After creation actions
134
            if ( $params->{type_disclaimer_submitted} ) {
135
                $type_disclaimer->after_request_created($params, $request);
136
            }
137
149
            $template->param(
138
            $template->param(
150
                whole   => $backend_result,
139
                whole   => $backend_result,
151
                request => $request
140
                request => $request
152
            );
141
            );
153
            handle_commit_maybe($backend_result, $request);
142
            handle_commit_maybe($backend_result, $request);
154
        }
143
        }
155
156
    } elsif ( $op eq 'migrate' ) {
144
    } elsif ( $op eq 'migrate' ) {
157
        # We're in the process of migrating a request
145
        # We're in the process of migrating a request
158
        my $request = Koha::Illrequests->find($params->{illrequest_id});
146
        my $request = Koha::Illrequests->find($params->{illrequest_id});
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt (-1 / +39 lines)
Lines 828-833 Link Here
828
                            [% INCLUDE 'ill-availability-table.inc' service=service %]
828
                            [% INCLUDE 'ill-availability-table.inc' service=service %]
829
                        [% END %]
829
                        [% END %]
830
                    </div>
830
                    </div>
831
                [% ELSIF query_type == 'typedisclaimer' %]
832
                    <!-- typedisclaimer -->
833
                    <h1>Request type disclaimer</h1>
834
                    <div id="results" class="page-section">
835
                        <form method="post" id="typedisclaimer-form">
836
                            <fieldset class="rows">
837
                                [% disclaimer.text | $raw %]
838
                                [% SET disc_av_category_code = AuthorisedValues.GetAuthValueDropbox(disclaimer.av_cat) %]
839
                                [% IF disc_av_category_code.count %]
840
                                <br>
841
                                    <select name="type_disclaimer_value">
842
                                        [% FOR av_option IN disc_av_category_code %]
843
                                            <option value="[% av_option.lib_opac | html %]">[% av_option.lib_opac | html %]</option>
844
                                        [% END %]
845
                                    </select>
846
                                [% END %]
847
                            </fieldset>
848
                            <fieldset class="action">
849
                                [% FOREACH key IN whole.keys %]
850
                                    [% value = whole.$key %]
851
                                    [% IF key != 'method' && key != 'custom_key' && key != 'custom_value' %]
852
                                        <input type="hidden" name="[% key | html %]" value="[% value | html %]">
853
                                    [% END %]
854
                                [% END %]
855
                                [% custom_keys = whole.custom_key.split('\0') %]
856
                                [% custom_values = whole.custom_value.split('\0') %]
857
                                [% i = 0 %]
858
                                [% FOREACH custom_key IN custom_keys %]
859
                                    <input type="hidden" name="custom_key" value="[% custom_key | html %]">
860
                                    <input type="hidden" name="custom_value" value="[% custom_values.$i | html %]">
861
                                    [% i = i + 1 %]
862
                                [% END %]
863
                                <input type="hidden" name="method" value="create" />
864
                                <input type="hidden" name="stage" value="form">
865
                                <input type="hidden" name="type_disclaimer_submitted" value="1">
866
                                <input type="submit" value="Next" />
867
                            </fieldset>
868
                        </form>
869
                    </div>
831
                [% ELSE %]
870
                [% ELSE %]
832
                <!-- Custom Backend Action -->
871
                <!-- Custom Backend Action -->
833
                [% PROCESS $whole.template %]
872
                [% PROCESS $whole.template %]
834
- 

Return to bug 33716