|
Lines 196-206
sub status_alias {
Link Here
|
| 196 |
my $current_status_alias = $self->SUPER::status_alias; |
196 |
my $current_status_alias = $self->SUPER::status_alias; |
| 197 |
|
197 |
|
| 198 |
if ($new_status_alias) { |
198 |
if ($new_status_alias) { |
|
|
199 |
# $new_status_alias may be one of two things, it may be a simple string |
| 200 |
# thereby just a drop in replacement for the native status_alias |
| 201 |
# method, but it may also be a hashref, as per: |
| 202 |
# |
| 203 |
# { status => '<new_status>', additional => {<arbitrary_hashref} } |
| 204 |
# |
| 205 |
# The purpose of 'additional' is to allow additional data to be |
| 206 |
# sent for logging when the status change is logged, in addition to |
| 207 |
# the new status. I'm not 100% happy with this solution, but since |
| 208 |
# we implcitly log when $request->status_alias(123) is called, I'm not |
| 209 |
# sure how else we can achieve it without explicitly calling logging |
| 210 |
# each time a status is changed, which would be grim |
| 211 |
# |
| 199 |
# Keep a record of the previous status before we change it, |
212 |
# Keep a record of the previous status before we change it, |
| 200 |
# we might need it |
213 |
# we might need it |
| 201 |
$self->{previous_status} = $current_status_alias ? |
214 |
$self->{previous_status} = $current_status_alias ? |
| 202 |
$current_status_alias : |
215 |
$current_status_alias : |
| 203 |
scalar $self->status; |
216 |
scalar $self->status; |
|
|
217 |
my $actual_status_alias; |
| 218 |
my $additional; |
| 219 |
if (ref $new_status_alias eq 'HASH') { |
| 220 |
$actual_status_alias = $new_status_alias->{status}; |
| 221 |
$additional = $new_status_alias->{additional} |
| 222 |
if exists $new_status_alias->{additional}; |
| 223 |
} else { |
| 224 |
$actual_status_alias = $new_status_alias; |
| 225 |
} |
| 204 |
# This is hackery to enable us to undefine |
226 |
# This is hackery to enable us to undefine |
| 205 |
# status_alias, since we need to have an overloaded |
227 |
# status_alias, since we need to have an overloaded |
| 206 |
# status_alias method to get us around the problem described |
228 |
# status_alias method to get us around the problem described |
|
Lines 208-221
sub status_alias {
Link Here
|
| 208 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
230 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
| 209 |
# We need a way of accepting implied undef, so we can nullify |
231 |
# We need a way of accepting implied undef, so we can nullify |
| 210 |
# the status_alias column, when called from $self->status |
232 |
# the status_alias column, when called from $self->status |
| 211 |
my $val = $new_status_alias eq "-1" ? undef : $new_status_alias; |
233 |
my $val = $actual_status_alias eq "-1" ? undef : $actual_status_alias; |
| 212 |
my $ret = $self->SUPER::status_alias($val); |
234 |
my $ret = $self->SUPER::status_alias($val); |
| 213 |
my $val_to_log = $val ? $new_status_alias : scalar $self->status; |
235 |
my $val_to_log = $val ? $actual_status_alias : scalar $self->status; |
| 214 |
if ($ret) { |
236 |
if ($ret) { |
| 215 |
my $logger = Koha::Illrequest::Logger->new; |
237 |
my $logger = Koha::Illrequest::Logger->new; |
| 216 |
$logger->log_status_change({ |
238 |
$logger->log_status_change({ |
| 217 |
request => $self, |
239 |
request => $self, |
| 218 |
value => $val_to_log |
240 |
value => { |
|
|
241 |
status => $val_to_log, |
| 242 |
additional => $additional |
| 243 |
} |
| 219 |
}); |
244 |
}); |
| 220 |
} else { |
245 |
} else { |
| 221 |
delete $self->{previous_status}; |
246 |
delete $self->{previous_status}; |
|
Lines 248-264
also nullifies status_alias and records the fact that the status has changed
Link Here
|
| 248 |
|
273 |
|
| 249 |
sub status { |
274 |
sub status { |
| 250 |
my ( $self, $new_status) = @_; |
275 |
my ( $self, $new_status) = @_; |
| 251 |
|
|
|
| 252 |
my $current_status = $self->SUPER::status; |
276 |
my $current_status = $self->SUPER::status; |
| 253 |
my $current_status_alias = $self->SUPER::status_alias; |
277 |
my $current_status_alias = $self->SUPER::status_alias; |
| 254 |
|
278 |
|
| 255 |
if ($new_status) { |
279 |
if ($new_status) { |
|
|
280 |
# $new_status may be one of two things, it may be a simple string |
| 281 |
# thereby just a drop in replacement for the native status method, |
| 282 |
# but it may also be a hashref, as per: |
| 283 |
# |
| 284 |
# { status => '<new_status>', additional => {<arbitrary_hashref} } |
| 285 |
# |
| 286 |
# The purpose of 'additional' is to allow additional data to be |
| 287 |
# sent for logging when the status change is logged, in addition to |
| 288 |
# the new status. I'm not 100% happy with this solution, but since |
| 289 |
# we implcitly log when $request->status('XYZ') is called, I'm not |
| 290 |
# sure how else we can achieve it without explicitly calling logging |
| 291 |
# each time a status is changed, which would be grim |
| 292 |
# |
| 256 |
# Keep a record of the previous status before we change it, |
293 |
# Keep a record of the previous status before we change it, |
| 257 |
# we might need it |
294 |
# we might need it |
| 258 |
$self->{previous_status} = $current_status_alias ? |
295 |
$self->{previous_status} = $current_status_alias ? |
| 259 |
$current_status_alias : |
296 |
$current_status_alias : |
| 260 |
$current_status; |
297 |
$current_status; |
| 261 |
my $ret = $self->SUPER::status($new_status)->store; |
298 |
my $actual_status; |
|
|
299 |
my $additional; |
| 300 |
if (ref $new_status eq 'HASH') { |
| 301 |
$actual_status = $new_status->{status}; |
| 302 |
$additional = $new_status->{additional} |
| 303 |
if exists $new_status->{additional}; |
| 304 |
} else { |
| 305 |
$actual_status = $new_status; |
| 306 |
} |
| 307 |
my $ret = $self->SUPER::status($actual_status)->store; |
| 262 |
if ($current_status_alias) { |
308 |
if ($current_status_alias) { |
| 263 |
# This is hackery to enable us to undefine |
309 |
# This is hackery to enable us to undefine |
| 264 |
# status_alias, since we need to have an overloaded |
310 |
# status_alias, since we need to have an overloaded |
|
Lines 267-278
sub status {
Link Here
|
| 267 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
313 |
# https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 |
| 268 |
# We need a way of passing implied undef to nullify status_alias |
314 |
# We need a way of passing implied undef to nullify status_alias |
| 269 |
# so we pass -1, which is special cased in the overloaded setter |
315 |
# so we pass -1, which is special cased in the overloaded setter |
| 270 |
$self->status_alias("-1"); |
316 |
$self->status_alias({ |
|
|
317 |
status => "-1", |
| 318 |
additional => $additional |
| 319 |
}); |
| 271 |
} else { |
320 |
} else { |
| 272 |
my $logger = Koha::Illrequest::Logger->new; |
321 |
my $logger = Koha::Illrequest::Logger->new; |
| 273 |
$logger->log_status_change({ |
322 |
$logger->log_status_change({ |
| 274 |
request => $self, |
323 |
request => $self, |
| 275 |
value => $new_status |
324 |
value => { |
|
|
325 |
status => $actual_status, |
| 326 |
additional => $additional |
| 327 |
} |
| 276 |
}); |
328 |
}); |
| 277 |
} |
329 |
} |
| 278 |
delete $self->{previous_status}; |
330 |
delete $self->{previous_status}; |
|
Lines 430-441
sub _core_status_graph {
Link Here
|
| 430 |
ui_method_icon => 'fa-check', |
482 |
ui_method_icon => 'fa-check', |
| 431 |
}, |
483 |
}, |
| 432 |
GENREQ => { |
484 |
GENREQ => { |
| 433 |
prev_actions => [ 'NEW', 'REQREV' ], |
485 |
prev_actions => [ 'NEW', 'REQREV', 'GENREQ' ], |
| 434 |
id => 'GENREQ', |
486 |
id => 'GENREQ', |
| 435 |
name => 'Requested from partners', |
487 |
name => 'Requested from partners', |
| 436 |
ui_method_name => 'Place request with partners', |
488 |
ui_method_name => 'Place request with partners', |
| 437 |
method => 'generic_confirm', |
489 |
method => 'generic_confirm', |
| 438 |
next_actions => [ 'COMP' ], |
490 |
next_actions => [ 'COMP', 'GENREQ' ], |
| 439 |
ui_method_icon => 'fa-send-o', |
491 |
ui_method_icon => 'fa-send-o', |
| 440 |
}, |
492 |
}, |
| 441 |
REQREV => { |
493 |
REQREV => { |
|
Lines 1118-1124
EOF
Link Here
|
| 1118 |
# Send it |
1170 |
# Send it |
| 1119 |
my $result = sendmail(%mail); |
1171 |
my $result = sendmail(%mail); |
| 1120 |
if ( $result ) { |
1172 |
if ( $result ) { |
| 1121 |
$self->status("GENREQ")->store; |
1173 |
# This request may previously have been sent to partners |
|
|
1174 |
# so we want to check who |
| 1175 |
my $previous_partners = $self->requested_partners; |
| 1176 |
$self->status({ |
| 1177 |
status => "GENREQ", |
| 1178 |
additional => { |
| 1179 |
partner_email_now => $to, |
| 1180 |
partner_email_previous => $previous_partners |
| 1181 |
} |
| 1182 |
})->store; |
| 1122 |
$self->_backend_capability( |
1183 |
$self->_backend_capability( |
| 1123 |
'set_requested_partners', |
1184 |
'set_requested_partners', |
| 1124 |
{ |
1185 |
{ |
|
Lines 1217-1232
sub store {
Link Here
|
| 1217 |
my $partners_string = $illRequest->requested_partners; |
1278 |
my $partners_string = $illRequest->requested_partners; |
| 1218 |
|
1279 |
|
| 1219 |
Return the string representing the email addresses of the partners to |
1280 |
Return the string representing the email addresses of the partners to |
| 1220 |
whom a request has been sent |
1281 |
whom a request has been sent or, alternatively, the full (unblessed) |
|
|
1282 |
patron objects in an arrayref |
| 1221 |
|
1283 |
|
| 1222 |
=cut |
1284 |
=cut |
| 1223 |
|
1285 |
|
| 1224 |
sub requested_partners { |
1286 |
sub requested_partners { |
| 1225 |
my ( $self ) = @_; |
1287 |
my ( $self, $full ) = @_; |
| 1226 |
return $self->_backend_capability( |
1288 |
my $email = $self->_backend_capability( |
| 1227 |
'get_requested_partners', |
1289 |
'get_requested_partners', |
| 1228 |
{ request => $self } |
1290 |
{ request => $self } |
| 1229 |
); |
1291 |
); |
|
|
1292 |
return $email if (!$full); |
| 1293 |
|
| 1294 |
# The string may contain multiple addressed delimited by '; ' |
| 1295 |
my @email_split = split(/; /, $email); |
| 1296 |
# Get the appropriate patron objects |
| 1297 |
return Koha::Patrons->search({ |
| 1298 |
email => { -in => \@email_split }, |
| 1299 |
categorycode => $self->_config->partner_code |
| 1300 |
})->unblessed; |
| 1230 |
} |
1301 |
} |
| 1231 |
|
1302 |
|
| 1232 |
=head3 TO_JSON |
1303 |
=head3 TO_JSON |