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