|
Lines 1-4
Link Here
|
| 1 |
package Koha::Illrequest::Workflow::TypeDisclaimer; |
1 |
package Koha::ILL::Request::Workflow::TypeDisclaimer; |
| 2 |
|
2 |
|
| 3 |
# Copyright 2023 PTFS Europe Ltd |
3 |
# Copyright 2023 PTFS Europe Ltd |
| 4 |
# |
4 |
# |
|
Lines 21-27
use Modern::Perl;
Link Here
|
| 21 |
|
21 |
|
| 22 |
use POSIX qw( strftime ); |
22 |
use POSIX qw( strftime ); |
| 23 |
|
23 |
|
| 24 |
use base qw(Koha::Illrequest::Workflow); |
24 |
use base qw(Koha::ILL::Request::Workflow); |
| 25 |
|
25 |
|
| 26 |
=head1 NAME |
26 |
=head1 NAME |
| 27 |
|
27 |
|
|
Lines 54-80
sub show_type_disclaimer {
Link Here
|
| 54 |
|
54 |
|
| 55 |
my $disc_sys_pref = $self->_get_type_disclaimer_sys_pref; |
55 |
my $disc_sys_pref = $self->_get_type_disclaimer_sys_pref; |
| 56 |
|
56 |
|
| 57 |
my $disc_info = |
57 |
my $disc_info = $self->_get_type_disclaimer_info( |
| 58 |
$self->_get_type_disclaimer_info( $self->_get_type_disclaimer_sys_pref, |
58 |
$self->_get_type_disclaimer_sys_pref, |
| 59 |
$self->{metadata}->{type} ); |
59 |
$self->{metadata}->{type} |
|
|
60 |
); |
| 60 |
|
61 |
|
| 61 |
return |
62 |
return |
| 62 |
|
63 |
|
| 63 |
# ILLModuleDisclaimerByType contains correct YAML |
64 |
# ILLModuleDisclaimerByType contains correct YAML |
| 64 |
%{$disc_sys_pref} |
65 |
%{$disc_sys_pref} |
| 65 |
|
66 |
|
| 66 |
# Check that we have info to display for this type |
67 |
# Check that we have info to display for this type |
| 67 |
&& $disc_info |
68 |
&& $disc_info |
| 68 |
|
69 |
|
| 69 |
# ILLModuleDisclaimerByType contains at least 'all' |
70 |
# ILLModuleDisclaimerByType contains at least 'all' |
| 70 |
&& $disc_sys_pref->{all} |
71 |
&& $disc_sys_pref->{all} |
| 71 |
|
72 |
|
| 72 |
# Type disclaimer has not yet been submitted |
73 |
# Type disclaimer has not yet been submitted |
| 73 |
&& !$self->{metadata}->{type_disclaimer_submitted} |
74 |
&& !$self->{metadata}->{type_disclaimer_submitted} |
| 74 |
|
75 |
|
| 75 |
# The form has been submitted and the backend is able to create the request |
76 |
# The form has been submitted and the backend is able to create the request |
| 76 |
&& $request->_backend_capability( 'can_create_request', |
77 |
&& $request->_backend_capability( |
| 77 |
$self->{metadata} ); |
78 |
'can_create_request', |
|
|
79 |
$self->{metadata} |
| 80 |
); |
| 78 |
} |
81 |
} |
| 79 |
|
82 |
|
| 80 |
=head3 type_disclaimer_template_params |
83 |
=head3 type_disclaimer_template_params |
|
Lines 90-101
Given $params, return true if type disclaimer should be rendered
Link Here
|
| 90 |
sub type_disclaimer_template_params { |
93 |
sub type_disclaimer_template_params { |
| 91 |
my ( $self, $params ) = @_; |
94 |
my ( $self, $params ) = @_; |
| 92 |
|
95 |
|
| 93 |
my $disc_info = |
96 |
my $disc_info = $self->_get_type_disclaimer_info( |
| 94 |
$self->_get_type_disclaimer_info( $self->_get_type_disclaimer_sys_pref, |
97 |
$self->_get_type_disclaimer_sys_pref, |
| 95 |
$params->{type} ); |
98 |
$params->{type} |
|
|
99 |
); |
| 96 |
|
100 |
|
| 97 |
$params->{method} = 'typedisclaimer' if $self->{ui_context} eq 'staff'; |
101 |
$params->{method} = 'typedisclaimer' if $self->{ui_context} eq 'staff'; |
| 98 |
delete $params->{stage} if $self->{ui_context} eq 'staff'; |
102 |
delete $params->{stage} if $self->{ui_context} eq 'staff'; |
| 99 |
|
103 |
|
| 100 |
return ( |
104 |
return ( |
| 101 |
whole => $params, |
105 |
whole => $params, |
|
Lines 129-135
sub after_request_created {
Link Here
|
| 129 |
value => strftime( "%Y-%m-%dT%H:%M:%S", localtime( time() ) ), |
133 |
value => strftime( "%Y-%m-%dT%H:%M:%S", localtime( time() ) ), |
| 130 |
readonly => 0 |
134 |
readonly => 0 |
| 131 |
}; |
135 |
}; |
| 132 |
Koha::Illrequestattribute->new($type_disclaimer_date)->store; |
136 |
Koha::ILL::Request::Attribute->new($type_disclaimer_date)->store; |
| 133 |
|
137 |
|
| 134 |
my $type_disclaimer_value = { |
138 |
my $type_disclaimer_value = { |
| 135 |
illrequest_id => $request->illrequest_id, |
139 |
illrequest_id => $request->illrequest_id, |
|
Lines 137-143
sub after_request_created {
Link Here
|
| 137 |
value => $params->{type_disclaimer_value}, |
141 |
value => $params->{type_disclaimer_value}, |
| 138 |
readonly => 0 |
142 |
readonly => 0 |
| 139 |
}; |
143 |
}; |
| 140 |
Koha::Illrequestattribute->new($type_disclaimer_value)->store; |
144 |
Koha::ILL::Request::Attribute->new($type_disclaimer_value)->store; |
| 141 |
} |
145 |
} |
| 142 |
|
146 |
|
| 143 |
=head3 _get_type_disclaimer_info |
147 |
=head3 _get_type_disclaimer_info |
|
Lines 154-160
sub _get_type_disclaimer_info {
Link Here
|
| 154 |
my ( $self, $disc_sys_pref, $type ) = @_; |
158 |
my ( $self, $disc_sys_pref, $type ) = @_; |
| 155 |
|
159 |
|
| 156 |
my @matching_request_type = |
160 |
my @matching_request_type = |
| 157 |
map ( $_ eq $type ? $_ : (), keys %$disc_sys_pref ); |
161 |
map ( $_ eq $type ? $_ : (), keys %$disc_sys_pref ); |
| 158 |
|
162 |
|
| 159 |
my $disc_info = undef; |
163 |
my $disc_info = undef; |
| 160 |
if ( scalar @matching_request_type ) { |
164 |
if ( scalar @matching_request_type ) { |
|
Lines 162-169
sub _get_type_disclaimer_info {
Link Here
|
| 162 |
|
166 |
|
| 163 |
$disc_info->{text} = $disc_sys_pref->{$type}->{text}; |
167 |
$disc_info->{text} = $disc_sys_pref->{$type}->{text}; |
| 164 |
$disc_info->{av_cat} = $disc_sys_pref->{$type}->{av_category_code}; |
168 |
$disc_info->{av_cat} = $disc_sys_pref->{$type}->{av_category_code}; |
| 165 |
} |
169 |
} elsif ( $disc_sys_pref->{all} ) { |
| 166 |
elsif ( $disc_sys_pref->{all} ) { |
|
|
| 167 |
$disc_info->{text} = $disc_sys_pref->{all}->{text}; |
170 |
$disc_info->{text} = $disc_sys_pref->{all}->{text}; |
| 168 |
$disc_info->{av_cat} = $disc_sys_pref->{all}->{av_category_code}; |
171 |
$disc_info->{av_cat} = $disc_sys_pref->{all}->{av_category_code}; |
| 169 |
} |
172 |
} |