|
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)) { |
| 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}); |
|
Lines 311-317
if ( $backends_available ) {
Link Here
|
| 311 |
# Prepare availability searching, if required |
299 |
# Prepare availability searching, if required |
| 312 |
# Get the definition for the z39.50 plugin |
300 |
# Get the definition for the z39.50 plugin |
| 313 |
if ( C4::Context->preference('ILLCheckAvailability') ) { |
301 |
if ( C4::Context->preference('ILLCheckAvailability') ) { |
| 314 |
my $availability = Koha::Illrequest::Availability->new($request->metadata); |
302 |
my $availability = Koha::Illrequest::Workflow::Availability->new($request->metadata); |
| 315 |
my $services = $availability->get_services({ |
303 |
my $services = $availability->get_services({ |
| 316 |
ui_context => 'partners', |
304 |
ui_context => 'partners', |
| 317 |
metadata => { |
305 |
metadata => { |