Lines 180-194
sub patron {
Link Here
|
180 |
} |
180 |
} |
181 |
|
181 |
|
182 |
=head3 status_alias |
182 |
=head3 status_alias |
|
|
183 |
|
184 |
$Illrequest->status_alias(143); |
185 |
|
183 |
Overloaded getter/setter for status_alias, |
186 |
Overloaded getter/setter for status_alias, |
184 |
that only returns authorised values from the |
187 |
that only returns authorised values from the |
185 |
correct category |
188 |
correct category and 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-208
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($val); |
211 |
my $ret = $self->SUPER::status_alias($val); |
201 |
if ($newval) { |
212 |
my $val_to_log = $val ? $new_status_alias : scalar $self->status; |
202 |
return $newval; |
213 |
if ($ret) { |
|
|
214 |
my $logger = Koha::Illrequest::Logger->new; |
215 |
$logger->log_status_change( |
216 |
$self, |
217 |
$val_to_log |
218 |
); |
203 |
} else { |
219 |
} else { |
204 |
return; |
220 |
delete $self->{previous_status}; |
205 |
} |
221 |
} |
|
|
222 |
return $ret; |
206 |
} |
223 |
} |
207 |
# We can't know which result is the right one if there are multiple |
224 |
# 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 |
225 |
# ILLSTATUS authorised values with the same authorised_value column value |
Lines 232-242
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->SUPER::status_alias; |
235 |
|
253 |
|
236 |
if ($new_status) { |
254 |
if ($new_status) { |
237 |
# Keep a record of the previous status before we change it, |
255 |
# Keep a record of the previous status before we change it, |
238 |
# we might need it |
256 |
# we might need it |
239 |
$self->{previous_status} = $current_status; |
257 |
$self->{previous_status} = $current_status_alias ? |
|
|
258 |
$current_status_alias : |
259 |
$current_status; |
240 |
my $ret = $self->SUPER::status($new_status)->store; |
260 |
my $ret = $self->SUPER::status($new_status)->store; |
241 |
if ($ret) { |
261 |
if ($ret) { |
242 |
# This is hackery to enable us to undefine |
262 |
# This is hackery to enable us to undefine |