Lines 202-212
sub status_alias {
Link Here
|
202 |
my $current_status_alias = $self->SUPER::status_alias; |
202 |
my $current_status_alias = $self->SUPER::status_alias; |
203 |
|
203 |
|
204 |
if ($new_status_alias) { |
204 |
if ($new_status_alias) { |
|
|
205 |
# $new_status_alias may be one of two things, it may be a simple string |
206 |
# thereby just a drop in replacement for the native status_alias |
207 |
# method, but it may also be a hashref, as per: |
208 |
# |
209 |
# { status => '<new_status>', additional => {<arbitrary_hashref} } |
210 |
# |
211 |
# The purpose of 'additional' is to allow additional data to be |
212 |
# sent for logging when the status change is logged, in addition to |
213 |
# the new status. I'm not 100% happy with this solution, but since |
214 |
# we implcitly log when $request->status_alias(123) is called, I'm not |
215 |
# sure how else we can achieve it without explicitly calling logging |
216 |
# each time a status is changed, which would be grim |
217 |
# |
205 |
# Keep a record of the previous status before we change it, |
218 |
# Keep a record of the previous status before we change it, |
206 |
# we might need it |
219 |
# we might need it |
207 |
$self->{previous_status} = $current_status_alias ? |
220 |
$self->{previous_status} = $current_status_alias ? |
208 |
$current_status_alias : |
221 |
$current_status_alias : |
209 |
scalar $self->status; |
222 |
scalar $self->status; |
|
|
223 |
my $actual_status_alias; |
224 |
my $additional; |
225 |
if (ref $new_status_alias eq 'HASH') { |
226 |
$actual_status_alias = $new_status_alias->{status}; |
227 |
$additional = $new_status_alias->{additional} |
228 |
if exists $new_status_alias->{additional}; |
229 |
} else { |
230 |
$actual_status_alias = $new_status_alias; |
231 |
} |
210 |
# This is hackery to enable us to undefine |
232 |
# This is hackery to enable us to undefine |
211 |
# status_alias, since we need to have an overloaded |
233 |
# status_alias, since we need to have an overloaded |
212 |
# status_alias method to get us around the problem described |
234 |
# status_alias method to get us around the problem described |
Lines 214-227
sub status_alias {
Link Here
|
214 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
236 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
215 |
# We need a way of accepting implied undef, so we can nullify |
237 |
# We need a way of accepting implied undef, so we can nullify |
216 |
# the status_alias column, when called from $self->status |
238 |
# the status_alias column, when called from $self->status |
217 |
my $val = $new_status_alias eq "-1" ? undef : $new_status_alias; |
239 |
my $val = $actual_status_alias eq "-1" ? undef : $actual_status_alias; |
218 |
my $ret = $self->SUPER::status_alias($val); |
240 |
my $ret = $self->SUPER::status_alias($val); |
219 |
my $val_to_log = $val ? $new_status_alias : scalar $self->status; |
241 |
my $val_to_log = $val ? $actual_status_alias : scalar $self->status; |
220 |
if ($ret) { |
242 |
if ($ret) { |
221 |
my $logger = Koha::Illrequest::Logger->new; |
243 |
my $logger = Koha::Illrequest::Logger->new; |
222 |
$logger->log_status_change({ |
244 |
$logger->log_status_change({ |
223 |
request => $self, |
245 |
request => $self, |
224 |
value => $val_to_log |
246 |
value => { |
|
|
247 |
status => $val_to_log, |
248 |
additional => $additional |
249 |
} |
225 |
}); |
250 |
}); |
226 |
} else { |
251 |
} else { |
227 |
delete $self->{previous_status}; |
252 |
delete $self->{previous_status}; |
Lines 259-275
and sends a notice if appropriate
Link Here
|
259 |
|
284 |
|
260 |
sub status { |
285 |
sub status { |
261 |
my ( $self, $new_status) = @_; |
286 |
my ( $self, $new_status) = @_; |
262 |
|
|
|
263 |
my $current_status = $self->SUPER::status; |
287 |
my $current_status = $self->SUPER::status; |
264 |
my $current_status_alias = $self->SUPER::status_alias; |
288 |
my $current_status_alias = $self->SUPER::status_alias; |
265 |
|
289 |
|
266 |
if ($new_status) { |
290 |
if ($new_status) { |
|
|
291 |
# $new_status may be one of two things, it may be a simple string |
292 |
# thereby just a drop in replacement for the native status method, |
293 |
# but it may also be a hashref, as per: |
294 |
# |
295 |
# { status => '<new_status>', additional => {<arbitrary_hashref} } |
296 |
# |
297 |
# The purpose of 'additional' is to allow additional data to be |
298 |
# sent for logging when the status change is logged, in addition to |
299 |
# the new status. I'm not 100% happy with this solution, but since |
300 |
# we implcitly log when $request->status('XYZ') is called, I'm not |
301 |
# sure how else we can achieve it without explicitly calling logging |
302 |
# each time a status is changed, which would be grim |
303 |
# |
267 |
# Keep a record of the previous status before we change it, |
304 |
# Keep a record of the previous status before we change it, |
268 |
# we might need it |
305 |
# we might need it |
269 |
$self->{previous_status} = $current_status_alias ? |
306 |
$self->{previous_status} = $current_status_alias ? |
270 |
$current_status_alias : |
307 |
$current_status_alias : |
271 |
$current_status; |
308 |
$current_status; |
272 |
my $ret = $self->SUPER::status($new_status)->store; |
309 |
my $actual_status; |
|
|
310 |
my $additional; |
311 |
if (ref $new_status eq 'HASH') { |
312 |
$actual_status = $new_status->{status}; |
313 |
$additional = $new_status->{additional} |
314 |
if exists $new_status->{additional}; |
315 |
} else { |
316 |
$actual_status = $new_status; |
317 |
} |
318 |
my $ret = $self->SUPER::status($actual_status)->store; |
273 |
if ($current_status_alias) { |
319 |
if ($current_status_alias) { |
274 |
# This is hackery to enable us to undefine |
320 |
# This is hackery to enable us to undefine |
275 |
# status_alias, since we need to have an overloaded |
321 |
# status_alias, since we need to have an overloaded |
Lines 278-289
sub status {
Link Here
|
278 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
324 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
279 |
# We need a way of passing implied undef to nullify status_alias |
325 |
# We need a way of passing implied undef to nullify status_alias |
280 |
# so we pass -1, which is special cased in the overloaded setter |
326 |
# so we pass -1, which is special cased in the overloaded setter |
281 |
$self->status_alias("-1"); |
327 |
$self->status_alias({ |
|
|
328 |
status => "-1", |
329 |
additional => $additional |
330 |
}); |
282 |
} else { |
331 |
} else { |
283 |
my $logger = Koha::Illrequest::Logger->new; |
332 |
my $logger = Koha::Illrequest::Logger->new; |
284 |
$logger->log_status_change({ |
333 |
$logger->log_status_change({ |
285 |
request => $self, |
334 |
request => $self, |
286 |
value => $new_status |
335 |
value => { |
|
|
336 |
status => $actual_status, |
337 |
additional => $additional |
338 |
} |
287 |
}); |
339 |
}); |
288 |
} |
340 |
} |
289 |
delete $self->{previous_status}; |
341 |
delete $self->{previous_status}; |
Lines 445-456
sub _core_status_graph {
Link Here
|
445 |
ui_method_icon => 'fa-check', |
497 |
ui_method_icon => 'fa-check', |
446 |
}, |
498 |
}, |
447 |
GENREQ => { |
499 |
GENREQ => { |
448 |
prev_actions => [ 'NEW', 'REQREV' ], |
500 |
prev_actions => [ 'NEW', 'REQREV', 'GENREQ' ], |
449 |
id => 'GENREQ', |
501 |
id => 'GENREQ', |
450 |
name => 'Requested from partners', |
502 |
name => 'Requested from partners', |
451 |
ui_method_name => 'Place request with partners', |
503 |
ui_method_name => 'Place request with partners', |
452 |
method => 'generic_confirm', |
504 |
method => 'generic_confirm', |
453 |
next_actions => [ 'COMP', 'CHK' ], |
505 |
next_actions => [ 'COMP', 'CHK', 'GENREQ' ], |
454 |
ui_method_icon => 'fa-send-o', |
506 |
ui_method_icon => 'fa-send-o', |
455 |
}, |
507 |
}, |
456 |
REQREV => { |
508 |
REQREV => { |
Lines 1363-1369
sub generic_confirm {
Link Here
|
1363 |
if ($letter) { |
1415 |
if ($letter) { |
1364 |
my $result = C4::Letters::EnqueueLetter($params); |
1416 |
my $result = C4::Letters::EnqueueLetter($params); |
1365 |
if ( $result ) { |
1417 |
if ( $result ) { |
1366 |
$self->status("GENREQ")->store; |
1418 |
# This request may previously have been sent to partners |
|
|
1419 |
# so we want to check who |
1420 |
my $previous_partners = $self->requested_partners; |
1421 |
$self->status({ |
1422 |
status => "GENREQ", |
1423 |
additional => { |
1424 |
partner_email_now => $to, |
1425 |
partner_email_previous => $previous_partners |
1426 |
} |
1427 |
})->store; |
1367 |
$self->_backend_capability( |
1428 |
$self->_backend_capability( |
1368 |
'set_requested_partners', |
1429 |
'set_requested_partners', |
1369 |
{ |
1430 |
{ |
Lines 1654-1669
sub store {
Link Here
|
1654 |
my $partners_string = $illRequest->requested_partners; |
1715 |
my $partners_string = $illRequest->requested_partners; |
1655 |
|
1716 |
|
1656 |
Return the string representing the email addresses of the partners to |
1717 |
Return the string representing the email addresses of the partners to |
1657 |
whom a request has been sent |
1718 |
whom a request has been sent or, alternatively, the full (unblessed) |
|
|
1719 |
patron objects in an arrayref |
1658 |
|
1720 |
|
1659 |
=cut |
1721 |
=cut |
1660 |
|
1722 |
|
1661 |
sub requested_partners { |
1723 |
sub requested_partners { |
1662 |
my ( $self ) = @_; |
1724 |
my ( $self, $full ) = @_; |
1663 |
return $self->_backend_capability( |
1725 |
my $email = $self->_backend_capability( |
1664 |
'get_requested_partners', |
1726 |
'get_requested_partners', |
1665 |
{ request => $self } |
1727 |
{ request => $self } |
1666 |
); |
1728 |
); |
|
|
1729 |
return $email if (!$full); |
1730 |
|
1731 |
# The string may contain multiple addressed delimited by '; ' |
1732 |
my @email_split = split(/; /, $email); |
1733 |
# Get the appropriate patron objects |
1734 |
return Koha::Patrons->search({ |
1735 |
email => { -in => \@email_split }, |
1736 |
categorycode => $self->_config->partner_code |
1737 |
})->unblessed; |
1667 |
} |
1738 |
} |
1668 |
|
1739 |
|
1669 |
=head3 TO_JSON |
1740 |
=head3 TO_JSON |