Lines 229-239
sub status_alias {
Link Here
|
229 |
my $current_status_alias = $self->SUPER::status_alias; |
229 |
my $current_status_alias = $self->SUPER::status_alias; |
230 |
|
230 |
|
231 |
if ($new_status_alias) { |
231 |
if ($new_status_alias) { |
|
|
232 |
# $new_status_alias may be one of two things, it may be a simple string |
233 |
# thereby just a drop in replacement for the native status_alias |
234 |
# method, but it may also be a hashref, as per: |
235 |
# |
236 |
# { status => '<new_status>', additional => {<arbitrary_hashref} } |
237 |
# |
238 |
# The purpose of 'additional' is to allow additional data to be |
239 |
# sent for logging when the status change is logged, in addition to |
240 |
# the new status. I'm not 100% happy with this solution, but since |
241 |
# we implcitly log when $request->status_alias(123) is called, I'm not |
242 |
# sure how else we can achieve it without explicitly calling logging |
243 |
# each time a status is changed, which would be grim |
244 |
# |
232 |
# Keep a record of the previous status before we change it, |
245 |
# Keep a record of the previous status before we change it, |
233 |
# we might need it |
246 |
# we might need it |
234 |
$self->{previous_status} = $current_status_alias ? |
247 |
$self->{previous_status} = $current_status_alias ? |
235 |
$current_status_alias : |
248 |
$current_status_alias : |
236 |
scalar $self->status; |
249 |
scalar $self->status; |
|
|
250 |
my $actual_status_alias; |
251 |
my $additional; |
252 |
if (ref $new_status_alias eq 'HASH') { |
253 |
$actual_status_alias = $new_status_alias->{status}; |
254 |
$additional = $new_status_alias->{additional} |
255 |
if exists $new_status_alias->{additional}; |
256 |
} else { |
257 |
$actual_status_alias = $new_status_alias; |
258 |
} |
237 |
# This is hackery to enable us to undefine |
259 |
# This is hackery to enable us to undefine |
238 |
# status_alias, since we need to have an overloaded |
260 |
# status_alias, since we need to have an overloaded |
239 |
# status_alias method to get us around the problem described |
261 |
# status_alias method to get us around the problem described |
Lines 241-254
sub status_alias {
Link Here
|
241 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
263 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
242 |
# We need a way of accepting implied undef, so we can nullify |
264 |
# We need a way of accepting implied undef, so we can nullify |
243 |
# the status_alias column, when called from $self->status |
265 |
# the status_alias column, when called from $self->status |
244 |
my $val = $new_status_alias eq "-1" ? undef : $new_status_alias; |
266 |
my $val = $actual_status_alias eq "-1" ? undef : $actual_status_alias; |
245 |
my $ret = $self->SUPER::status_alias($val); |
267 |
my $ret = $self->SUPER::status_alias($val); |
246 |
my $val_to_log = $val ? $new_status_alias : scalar $self->status; |
268 |
my $val_to_log = $val ? $actual_status_alias : scalar $self->status; |
247 |
if ($ret) { |
269 |
if ($ret) { |
248 |
my $logger = Koha::Illrequest::Logger->new; |
270 |
my $logger = Koha::Illrequest::Logger->new; |
249 |
$logger->log_status_change({ |
271 |
$logger->log_status_change({ |
250 |
request => $self, |
272 |
request => $self, |
251 |
value => $val_to_log |
273 |
value => { |
|
|
274 |
status => $val_to_log, |
275 |
additional => $additional |
276 |
} |
252 |
}); |
277 |
}); |
253 |
} else { |
278 |
} else { |
254 |
delete $self->{previous_status}; |
279 |
delete $self->{previous_status}; |
Lines 286-302
and sends a notice if appropriate
Link Here
|
286 |
|
311 |
|
287 |
sub status { |
312 |
sub status { |
288 |
my ( $self, $new_status) = @_; |
313 |
my ( $self, $new_status) = @_; |
289 |
|
|
|
290 |
my $current_status = $self->SUPER::status; |
314 |
my $current_status = $self->SUPER::status; |
291 |
my $current_status_alias = $self->SUPER::status_alias; |
315 |
my $current_status_alias = $self->SUPER::status_alias; |
292 |
|
316 |
|
293 |
if ($new_status) { |
317 |
if ($new_status) { |
|
|
318 |
# $new_status may be one of two things, it may be a simple string |
319 |
# thereby just a drop in replacement for the native status method, |
320 |
# but it may also be a hashref, as per: |
321 |
# |
322 |
# { status => '<new_status>', additional => {<arbitrary_hashref} } |
323 |
# |
324 |
# The purpose of 'additional' is to allow additional data to be |
325 |
# sent for logging when the status change is logged, in addition to |
326 |
# the new status. I'm not 100% happy with this solution, but since |
327 |
# we implcitly log when $request->status('XYZ') is called, I'm not |
328 |
# sure how else we can achieve it without explicitly calling logging |
329 |
# each time a status is changed, which would be grim |
330 |
# |
294 |
# Keep a record of the previous status before we change it, |
331 |
# Keep a record of the previous status before we change it, |
295 |
# we might need it |
332 |
# we might need it |
296 |
$self->{previous_status} = $current_status_alias ? |
333 |
$self->{previous_status} = $current_status_alias ? |
297 |
$current_status_alias : |
334 |
$current_status_alias : |
298 |
$current_status; |
335 |
$current_status; |
299 |
my $ret = $self->SUPER::status($new_status)->store; |
336 |
my $actual_status; |
|
|
337 |
my $additional; |
338 |
if (ref $new_status eq 'HASH') { |
339 |
$actual_status = $new_status->{status}; |
340 |
$additional = $new_status->{additional} |
341 |
if exists $new_status->{additional}; |
342 |
} else { |
343 |
$actual_status = $new_status; |
344 |
} |
345 |
my $ret = $self->SUPER::status($actual_status)->store; |
300 |
if ($current_status_alias) { |
346 |
if ($current_status_alias) { |
301 |
# This is hackery to enable us to undefine |
347 |
# This is hackery to enable us to undefine |
302 |
# status_alias, since we need to have an overloaded |
348 |
# status_alias, since we need to have an overloaded |
Lines 305-316
sub status {
Link Here
|
305 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
351 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
306 |
# We need a way of passing implied undef to nullify status_alias |
352 |
# We need a way of passing implied undef to nullify status_alias |
307 |
# so we pass -1, which is special cased in the overloaded setter |
353 |
# so we pass -1, which is special cased in the overloaded setter |
308 |
$self->status_alias("-1"); |
354 |
$self->status_alias({ |
|
|
355 |
status => "-1", |
356 |
additional => $additional |
357 |
}); |
309 |
} else { |
358 |
} else { |
310 |
my $logger = Koha::Illrequest::Logger->new; |
359 |
my $logger = Koha::Illrequest::Logger->new; |
311 |
$logger->log_status_change({ |
360 |
$logger->log_status_change({ |
312 |
request => $self, |
361 |
request => $self, |
313 |
value => $new_status |
362 |
value => { |
|
|
363 |
status => $actual_status, |
364 |
additional => $additional |
365 |
} |
314 |
}); |
366 |
}); |
315 |
} |
367 |
} |
316 |
delete $self->{previous_status}; |
368 |
delete $self->{previous_status}; |
Lines 473-484
sub _core_status_graph {
Link Here
|
473 |
ui_method_icon => 'fa-check', |
525 |
ui_method_icon => 'fa-check', |
474 |
}, |
526 |
}, |
475 |
GENREQ => { |
527 |
GENREQ => { |
476 |
prev_actions => [ 'NEW', 'REQREV' ], |
528 |
prev_actions => [ 'NEW', 'REQREV', 'GENREQ' ], |
477 |
id => 'GENREQ', |
529 |
id => 'GENREQ', |
478 |
name => 'Requested from partners', |
530 |
name => 'Requested from partners', |
479 |
ui_method_name => 'Place request with partners', |
531 |
ui_method_name => 'Place request with partners', |
480 |
method => 'generic_confirm', |
532 |
method => 'generic_confirm', |
481 |
next_actions => [ 'COMP', 'CHK' ], |
533 |
next_actions => [ 'COMP', 'CHK', 'GENREQ' ], |
482 |
ui_method_icon => 'fa-send-o', |
534 |
ui_method_icon => 'fa-send-o', |
483 |
}, |
535 |
}, |
484 |
REQREV => { |
536 |
REQREV => { |
Lines 1440-1445
sub generic_confirm {
Link Here
|
1440 |
}; |
1492 |
}; |
1441 |
my $result = C4::Letters::EnqueueLetter($params); |
1493 |
my $result = C4::Letters::EnqueueLetter($params); |
1442 |
if ( $result ) { |
1494 |
if ( $result ) { |
|
|
1495 |
# This request may previously have been sent to partners |
1496 |
# so we want to check who |
1497 |
my $previous_partners = $self->requested_partners; |
1498 |
$self->status({ |
1499 |
status => "GENREQ", |
1500 |
additional => { |
1501 |
partner_email_now => $to, |
1502 |
partner_email_previous => $previous_partners |
1503 |
} |
1504 |
})->store; |
1443 |
push @queued, $patron->email; |
1505 |
push @queued, $patron->email; |
1444 |
} |
1506 |
} |
1445 |
} |
1507 |
} |
Lines 1799-1814
sub store {
Link Here
|
1799 |
my $partners_string = $illRequest->requested_partners; |
1861 |
my $partners_string = $illRequest->requested_partners; |
1800 |
|
1862 |
|
1801 |
Return the string representing the email addresses of the partners to |
1863 |
Return the string representing the email addresses of the partners to |
1802 |
whom a request has been sent |
1864 |
whom a request has been sent or, alternatively, the full (unblessed) |
|
|
1865 |
patron objects in an arrayref |
1803 |
|
1866 |
|
1804 |
=cut |
1867 |
=cut |
1805 |
|
1868 |
|
1806 |
sub requested_partners { |
1869 |
sub requested_partners { |
1807 |
my ( $self ) = @_; |
1870 |
my ( $self, $full ) = @_; |
1808 |
return $self->_backend_capability( |
1871 |
my $email = $self->_backend_capability( |
1809 |
'get_requested_partners', |
1872 |
'get_requested_partners', |
1810 |
{ request => $self } |
1873 |
{ request => $self } |
1811 |
); |
1874 |
); |
|
|
1875 |
return $email if (!$full); |
1876 |
|
1877 |
# The string may contain multiple addressed delimited by '; ' |
1878 |
my @email_split = split(/; /, $email); |
1879 |
# Get the appropriate patron objects |
1880 |
return Koha::Patrons->search({ |
1881 |
email => { -in => \@email_split }, |
1882 |
categorycode => $self->_config->partner_code |
1883 |
})->unblessed; |
1812 |
} |
1884 |
} |
1813 |
|
1885 |
|
1814 |
=head3 TO_JSON |
1886 |
=head3 TO_JSON |