Lines 180-194
sub patron {
Link Here
|
180 |
} |
180 |
} |
181 |
|
181 |
|
182 |
=head3 status_alias |
182 |
=head3 status_alias |
183 |
Overloaded getter/setter for status_alias, |
183 |
|
184 |
that only returns authorised values from the |
184 |
$Illrequest->status_alias('CUSTOM_AV'); |
185 |
correct category |
185 |
|
|
|
186 |
Overloaded getter/setter for request status_alias, |
187 |
returns authorised values from the correct category, |
188 |
also records the fact that the status has changed |
186 |
|
189 |
|
187 |
=cut |
190 |
=cut |
188 |
|
191 |
|
189 |
sub status_alias { |
192 |
sub status_alias { |
190 |
my ($self, $newval) = @_; |
193 |
my ($self, $new_status_alias) = @_; |
191 |
if ($newval) { |
194 |
|
|
|
195 |
my $current_status_alias = $self->SUPER::status_alias; |
196 |
|
197 |
if ($new_status_alias) { |
198 |
# Keep a record of the previous status before we change it, |
199 |
# we might need it |
200 |
$self->{previous_status} = $current_status_alias ? |
201 |
$current_status_alias : |
202 |
scalar $self->status; |
192 |
# This is hackery to enable us to undefine |
203 |
# This is hackery to enable us to undefine |
193 |
# status_alias, since we need to have an overloaded |
204 |
# status_alias, since we need to have an overloaded |
194 |
# status_alias method to get us around the problem described |
205 |
# status_alias method to get us around the problem described |
Lines 196-221
sub status_alias {
Link Here
|
196 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
207 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
197 |
# We need a way of accepting implied undef, so we can nullify |
208 |
# We need a way of accepting implied undef, so we can nullify |
198 |
# the status_alias column, when called from $self->status |
209 |
# the status_alias column, when called from $self->status |
199 |
my $val = $newval eq "-1" ? undef : $newval; |
210 |
my $val = $new_status_alias eq "-1" ? undef : $new_status_alias; |
200 |
my $newval = $self->SUPER::status_alias($newval); |
211 |
my $ret = $self->SUPER::status_alias($val)->store; |
201 |
if ($newval) { |
212 |
if ($ret) { |
202 |
return $newval; |
213 |
my $logger = Koha::Illrequest::Logger->new; |
|
|
214 |
$logger->log_status_change( |
215 |
$self, |
216 |
$new_status_alias |
217 |
); |
203 |
} else { |
218 |
} else { |
204 |
return; |
219 |
delete $self->{previous_status}; |
205 |
} |
220 |
} |
206 |
} |
221 |
return $ret; |
207 |
# We can't know which result is the right one if there are multiple |
|
|
208 |
# ILLSTATUS authorised values with the same authorised_value column value |
209 |
# so we just use the first |
210 |
my $alias = Koha::AuthorisedValues->search({ |
211 |
branchcode => $self->branchcode, |
212 |
category => 'ILLSTATUS', |
213 |
authorised_value => $self->SUPER::status_alias |
214 |
})->next; |
215 |
if ($alias) { |
216 |
return $alias->authorised_value; |
217 |
} else { |
222 |
} else { |
218 |
return; |
223 |
# We can't know which result is the right one if there are multiple |
|
|
224 |
# ILLSTATUS authorised values with the same authorised_value column |
225 |
# value so we just use the first |
226 |
my $alias = Koha::AuthorisedValues->search({ |
227 |
branchcode => $self->branchcode, |
228 |
category => 'ILLSTATUS', |
229 |
authorised_value => $current_status_alias |
230 |
})->next; |
231 |
if ($alias) { |
232 |
return $alias->authorised_value; |
233 |
} else { |
234 |
return; |
235 |
} |
219 |
} |
236 |
} |
220 |
} |
237 |
} |
221 |
|
238 |
|
Lines 232-237
sub status {
Link Here
|
232 |
my ( $self, $new_status) = @_; |
249 |
my ( $self, $new_status) = @_; |
233 |
|
250 |
|
234 |
my $current_status = $self->SUPER::status; |
251 |
my $current_status = $self->SUPER::status; |
|
|
252 |
my $current_status_alias = $self->status_alias; |
235 |
|
253 |
|
236 |
if ($new_status) { |
254 |
if ($new_status) { |
237 |
# This is hackery to enable us to undefine |
255 |
# This is hackery to enable us to undefine |
Lines 244-250
sub status {
Link Here
|
244 |
# |
262 |
# |
245 |
# Keep a record of the previous status before we change it, |
263 |
# Keep a record of the previous status before we change it, |
246 |
# we might need it |
264 |
# we might need it |
247 |
$self->{previous_status} = $current_status; |
265 |
$self->{previous_status} = $current_status_alias ? |
|
|
266 |
$current_status_alias : |
267 |
$current_status; |
248 |
my $ret = $self->SUPER::status($new_status)->store; |
268 |
my $ret = $self->SUPER::status($new_status)->store; |
249 |
if ($ret) { |
269 |
if ($ret) { |
250 |
$self->status_alias("-1"); |
270 |
$self->status_alias("-1"); |