|
Lines 25-36
use CGI qw ( -utf8 );
Link Here
|
| 25 |
use C4::Auth qw( get_template_and_user ); |
25 |
use C4::Auth qw( get_template_and_user ); |
| 26 |
use C4::Koha; |
26 |
use C4::Koha; |
| 27 |
use C4::Output qw( output_html_with_http_headers ); |
27 |
use C4::Output qw( output_html_with_http_headers ); |
|
|
28 |
use POSIX qw( strftime ); |
| 28 |
|
29 |
|
| 29 |
use Koha::Illrequest::Config; |
30 |
use Koha::Illrequest::Config; |
| 30 |
use Koha::Illrequests; |
31 |
use Koha::Illrequests; |
| 31 |
use Koha::Libraries; |
32 |
use Koha::Libraries; |
| 32 |
use Koha::Patrons; |
33 |
use Koha::Patrons; |
| 33 |
use Koha::Illrequest::Availability; |
34 |
use Koha::Illrequest::Workflow::Availability; |
|
|
35 |
use Koha::Illrequest::Workflow::TypeDisclaimer; |
| 34 |
|
36 |
|
| 35 |
my $query = CGI->new; |
37 |
my $query = CGI->new; |
| 36 |
|
38 |
|
|
Lines 115-157
if ( $op eq 'list' ) {
Link Here
|
| 115 |
my $request = Koha::Illrequest->new |
117 |
my $request = Koha::Illrequest->new |
| 116 |
->load_backend($params->{backend}); |
118 |
->load_backend($params->{backend}); |
| 117 |
|
119 |
|
| 118 |
# Does this backend enable us to insert an availability stage and should |
120 |
# Before request creation operations - Preparation |
| 119 |
# we? If not, proceed as normal. |
121 |
my $availability = |
| 120 |
if ( |
122 |
Koha::Illrequest::Workflow::Availability->new( $params, 'opac' ); |
| 121 |
C4::Context->preference("ILLCheckAvailability") && |
123 |
my $type_disclaimer = |
| 122 |
$request->_backend_capability( |
124 |
Koha::Illrequest::Workflow::TypeDisclaimer->new( $params, 'opac' ); |
| 123 |
'should_display_availability', |
125 |
|
| 124 |
$params |
126 |
# ILLCheckAvailability operation |
| 125 |
) && |
127 |
if ($availability->show_availability($request)) { |
| 126 |
# If the user has elected to continue with the request despite |
128 |
$op = 'availability'; |
| 127 |
# having viewed availability info, this flag will be set |
129 |
$template->param( |
| 128 |
!$params->{checked_availability} |
130 |
$availability->availability_template_params($params) |
| 129 |
) { |
131 |
); |
| 130 |
# Establish which of the installed availability providers |
132 |
output_html_with_http_headers $query, $cookie, |
| 131 |
# can service our metadata, if so, jump in |
133 |
$template->output, undef, |
| 132 |
my $availability = Koha::Illrequest::Availability->new($params); |
134 |
{ force_no_caching => 1 }; |
| 133 |
my $services = $availability->get_services({ |
135 |
exit; |
| 134 |
ui_context => 'opac' |
136 |
# ILLModuleDisclaimerByType operation |
| 135 |
}); |
137 |
} elsif ( $type_disclaimer->show_type_disclaimer($request, $params)) { |
| 136 |
if (scalar @{$services} > 0) { |
138 |
$op = 'typedisclaimer'; |
| 137 |
# Modify our method so we use the correct part of the |
139 |
$template->param( |
| 138 |
# template |
140 |
$type_disclaimer->type_disclaimer_template_params($params) |
| 139 |
$op = 'availability'; |
141 |
); |
| 140 |
# Prepare the metadata we're sending them |
142 |
output_html_with_http_headers $query, $cookie, |
| 141 |
my $metadata = $availability->prep_metadata($params); |
143 |
$template->output, undef, |
| 142 |
$template->param( |
144 |
{ force_no_caching => 1 }; |
| 143 |
metadata => $metadata, |
145 |
exit; |
| 144 |
services_json => encode_json($services), |
|
|
| 145 |
services => $services, |
| 146 |
illrequestsview => 1, |
| 147 |
message => $params->{message}, |
| 148 |
method => $op, |
| 149 |
whole => $params |
| 150 |
); |
| 151 |
output_html_with_http_headers $query, $cookie, |
| 152 |
$template->output, undef, { force_no_caching => 1 }; |
| 153 |
exit; |
| 154 |
} |
| 155 |
} |
146 |
} |
| 156 |
|
147 |
|
| 157 |
$params->{cardnumber} = Koha::Patrons->find({ |
148 |
$params->{cardnumber} = Koha::Patrons->find({ |
|
Lines 159-164
if ( $op eq 'list' ) {
Link Here
|
| 159 |
})->cardnumber; |
150 |
})->cardnumber; |
| 160 |
$params->{opac} = 1; |
151 |
$params->{opac} = 1; |
| 161 |
my $backend_result = $request->backend_create($params); |
152 |
my $backend_result = $request->backend_create($params); |
|
|
153 |
|
| 154 |
# After creation actions |
| 155 |
if ( $params->{type_disclaimer_submitted} ) { |
| 156 |
$type_disclaimer->after_request_created( $params, $request ); |
| 157 |
print $query->redirect('/cgi-bin/koha/opac-illrequests.pl?message=2'); |
| 158 |
exit; |
| 159 |
} |
| 160 |
|
| 162 |
if ($backend_result->{stage} eq 'copyrightclearance') { |
161 |
if ($backend_result->{stage} eq 'copyrightclearance') { |
| 163 |
$template->param( |
162 |
$template->param( |
| 164 |
stage => $backend_result->{stage}, |
163 |
stage => $backend_result->{stage}, |
| 165 |
- |
|
|