Lines 108-118
Returns the related Koha::Checkout object for this recall.
Link Here
|
108 |
|
108 |
|
109 |
sub checkout { |
109 |
sub checkout { |
110 |
my ( $self ) = @_; |
110 |
my ( $self ) = @_; |
111 |
$self->{_checkout} ||= Koha::Checkouts->find({ itemnumber => $self->itemnumber }); |
111 |
$self->{_checkout} ||= Koha::Checkouts->find({ itemnumber => $self->item_id }); |
112 |
|
112 |
|
113 |
unless ( $self->item_level_recall ) { |
113 |
unless ( $self->item_level ) { |
114 |
# Only look at checkouts of items that are allowed to be recalled, and get the oldest one |
114 |
# Only look at checkouts of items that are allowed to be recalled, and get the oldest one |
115 |
my @items = Koha::Items->search({ biblionumber => $self->biblionumber })->as_list; |
115 |
my @items = Koha::Items->search({ biblionumber => $self->biblio_id })->as_list; |
116 |
my @itemnumbers; |
116 |
my @itemnumbers; |
117 |
foreach (@items) { |
117 |
foreach (@items) { |
118 |
my $recalls_allowed = Koha::CirculationRules->get_effective_rule({ |
118 |
my $recalls_allowed = Koha::CirculationRules->get_effective_rule({ |
Lines 250-256
sub calc_expirationdate {
Link Here
|
250 |
my ( $self ) = @_; |
250 |
my ( $self ) = @_; |
251 |
|
251 |
|
252 |
my $item; |
252 |
my $item; |
253 |
if ( $self->item_level_recall ) { |
253 |
if ( $self->item_level ) { |
254 |
$item = $self->item; |
254 |
$item = $self->item; |
255 |
} elsif ( $self->checkout ) { |
255 |
} elsif ( $self->checkout ) { |
256 |
$item = $self->checkout->item; |
256 |
$item = $self->checkout->item; |
Lines 285-299
Set the recall as in transit.
Link Here
|
285 |
sub start_transfer { |
285 |
sub start_transfer { |
286 |
my ( $self, $params ) = @_; |
286 |
my ( $self, $params ) = @_; |
287 |
|
287 |
|
288 |
if ( $self->item_level_recall ) { |
288 |
if ( $self->item_level ) { |
289 |
# already has an itemnumber |
289 |
# already has an itemnumber |
290 |
$self->update({ status => 'in_transit' }); |
290 |
$self->update({ status => 'in_transit' }); |
291 |
} else { |
291 |
} else { |
292 |
my $itemnumber = $params->{item}->itemnumber; |
292 |
my $itemnumber = $params->{item}->itemnumber; |
293 |
$self->update({ status => 'in_transit', itemnumber => $itemnumber }); |
293 |
$self->update({ status => 'in_transit', item_id => $itemnumber }); |
294 |
} |
294 |
} |
295 |
|
295 |
|
296 |
my ( $dotransfer, $messages ) = C4::Circulation::transferbook({ to_branch => $self->branchcode, from_branch => $self->item->holdingbranch, barcode => $self->item->barcode, trigger => 'Recall' }); |
296 |
my ( $dotransfer, $messages ) = C4::Circulation::transferbook({ to_branch => $self->pickup_library_id, from_branch => $self->item->holdingbranch, barcode => $self->item->barcode, trigger => 'Recall' }); |
297 |
|
297 |
|
298 |
return ( $self, $dotransfer, $messages ); |
298 |
return ( $self, $dotransfer, $messages ); |
299 |
} |
299 |
} |
Lines 309-318
If a transfer is cancelled, revert the recall to requested.
Link Here
|
309 |
sub revert_transfer { |
309 |
sub revert_transfer { |
310 |
my ( $self ) = @_; |
310 |
my ( $self ) = @_; |
311 |
|
311 |
|
312 |
if ( $self->item_level_recall ) { |
312 |
if ( $self->item_level ) { |
313 |
$self->update({ status => 'requested' }); |
313 |
$self->update({ status => 'requested' }); |
314 |
} else { |
314 |
} else { |
315 |
$self->update({ status => 'requested', itemnumber => undef }); |
315 |
$self->update({ status => 'requested', item_id => undef }); |
316 |
} |
316 |
} |
317 |
|
317 |
|
318 |
return $self; |
318 |
return $self; |
Lines 335-360
sub set_waiting {
Link Here
|
335 |
my ( $self, $params ) = @_; |
335 |
my ( $self, $params ) = @_; |
336 |
|
336 |
|
337 |
my $itemnumber; |
337 |
my $itemnumber; |
338 |
if ( $self->item_level_recall ) { |
338 |
if ( $self->item_level ) { |
339 |
$itemnumber = $self->itemnumber; |
339 |
$itemnumber = $self->item_id; |
340 |
$self->update({ status => 'waiting', waitingdate => dt_from_string, expirationdate => $params->{expirationdate} }); |
340 |
$self->update({ status => 'waiting', waiting_date => dt_from_string, expiration_date => $params->{expirationdate} }); |
341 |
} else { |
341 |
} else { |
342 |
# biblio-level recall with no itemnumber. need to set itemnumber |
342 |
# biblio-level recall with no itemnumber. need to set itemnumber |
343 |
$itemnumber = $params->{item}->itemnumber; |
343 |
$itemnumber = $params->{item}->itemnumber; |
344 |
$self->update({ status => 'waiting', waitingdate => dt_from_string, expirationdate => $params->{expirationdate}, itemnumber => $itemnumber }); |
344 |
$self->update({ status => 'waiting', waiting_date => dt_from_string, expiration_date => $params->{expirationdate}, item_id => $itemnumber }); |
345 |
} |
345 |
} |
346 |
|
346 |
|
347 |
# send notice to recaller to pick up item |
347 |
# send notice to recaller to pick up item |
348 |
my $letter = C4::Letters::GetPreparedLetter( |
348 |
my $letter = C4::Letters::GetPreparedLetter( |
349 |
module => 'circulation', |
349 |
module => 'circulation', |
350 |
letter_code => 'PICKUP_RECALLED_ITEM', |
350 |
letter_code => 'PICKUP_RECALLED_ITEM', |
351 |
branchcode => $self->branchcode, |
351 |
branchcode => $self->pickup_library_id, |
352 |
want_librarian => 0, |
352 |
want_librarian => 0, |
353 |
tables => { |
353 |
tables => { |
354 |
biblio => $self->biblionumber, |
354 |
biblio => $self->biblio_id, |
355 |
borrowers => $self->borrowernumber, |
355 |
borrowers => $self->patron_id, |
356 |
items => $itemnumber, |
356 |
items => $itemnumber, |
357 |
recalls => $self->recall_id, |
357 |
recalls => $self->id, |
358 |
}, |
358 |
}, |
359 |
); |
359 |
); |
360 |
|
360 |
|
Lines 373-382
Revert recall waiting status.
Link Here
|
373 |
|
373 |
|
374 |
sub revert_waiting { |
374 |
sub revert_waiting { |
375 |
my ( $self ) = @_; |
375 |
my ( $self ) = @_; |
376 |
if ( $self->item_level_recall ){ |
376 |
if ( $self->item_level ){ |
377 |
$self->update({ status => 'requested', waitingdate => undef }); |
377 |
$self->update({ status => 'requested', waiting_date => undef }); |
378 |
} else { |
378 |
} else { |
379 |
$self->update({ status => 'requested', waitingdate => undef, itemnumber => undef }); |
379 |
$self->update({ status => 'requested', waiting_date => undef, item_id => undef }); |
380 |
} |
380 |
} |
381 |
return $self; |
381 |
return $self; |
382 |
} |
382 |
} |
Lines 411-417
sub set_overdue {
Link Here
|
411 |
my ( $self, $params ) = @_; |
411 |
my ( $self, $params ) = @_; |
412 |
my $interface = $params->{interface} || 'COMMANDLINE'; |
412 |
my $interface = $params->{interface} || 'COMMANDLINE'; |
413 |
$self->update({ status => 'overdue' }); |
413 |
$self->update({ status => 'overdue' }); |
414 |
C4::Log::logaction( 'RECALLS', 'OVERDUE', $self->recall_id, "Recall status set to overdue", $interface ) if ( C4::Context->preference('RecallsLog') ); |
414 |
C4::Log::logaction( 'RECALLS', 'OVERDUE', $self->id, "Recall status set to overdue", $interface ) if ( C4::Context->preference('RecallsLog') ); |
415 |
return $self; |
415 |
return $self; |
416 |
} |
416 |
} |
417 |
|
417 |
|
Lines 426-433
Set a recall as expired. This may be done manually or by a cronjob, either when
Link Here
|
426 |
sub set_expired { |
426 |
sub set_expired { |
427 |
my ( $self, $params ) = @_; |
427 |
my ( $self, $params ) = @_; |
428 |
my $interface = $params->{interface} || 'COMMANDLINE'; |
428 |
my $interface = $params->{interface} || 'COMMANDLINE'; |
429 |
$self->update({ status => 'expired', old => 1, expirationdate => dt_from_string }); |
429 |
$self->update({ status => 'expired', completed => 1, completed_date => dt_from_string }); |
430 |
C4::Log::logaction( 'RECALLS', 'EXPIRE', $self->recall_id, "Recall expired", $interface ) if ( C4::Context->preference('RecallsLog') ); |
430 |
C4::Log::logaction( 'RECALLS', 'EXPIRE', $self->id, "Recall expired", $interface ) if ( C4::Context->preference('RecallsLog') ); |
431 |
return $self; |
431 |
return $self; |
432 |
} |
432 |
} |
433 |
|
433 |
|
Lines 441-448
Set a recall as cancelled. This may be done manually, either by the borrower tha
Link Here
|
441 |
|
441 |
|
442 |
sub set_cancelled { |
442 |
sub set_cancelled { |
443 |
my ( $self ) = @_; |
443 |
my ( $self ) = @_; |
444 |
$self->update({ status => 'cancelled', old => 1, cancellationdate => dt_from_string }); |
444 |
$self->update({ status => 'cancelled', completed => 1, completed_date => dt_from_string }); |
445 |
C4::Log::logaction( 'RECALLS', 'CANCEL', $self->recall_id, "Recall cancelled", 'INTRANET' ) if ( C4::Context->preference('RecallsLog') ); |
445 |
C4::Log::logaction( 'RECALLS', 'CANCEL', $self->id, "Recall cancelled", 'INTRANET' ) if ( C4::Context->preference('RecallsLog') ); |
446 |
return $self; |
446 |
return $self; |
447 |
} |
447 |
} |
448 |
|
448 |
|
Lines 456-463
Set a recall as finished. This should only be called when the item allocated to
Link Here
|
456 |
|
456 |
|
457 |
sub set_fulfilled { |
457 |
sub set_fulfilled { |
458 |
my ( $self ) = @_; |
458 |
my ( $self ) = @_; |
459 |
$self->update({ status => 'fulfilled', old => 1 }); |
459 |
$self->update({ status => 'fulfilled', completed => 1, completed_date => dt_from_string }); |
460 |
C4::Log::logaction( 'RECALLS', 'FULFILL', $self->recall_id, "Recall fulfilled", 'INTRANET' ) if ( C4::Context->preference('RecallsLog') ); |
460 |
C4::Log::logaction( 'RECALLS', 'FULFILL', $self->id, "Recall fulfilled", 'INTRANET' ) if ( C4::Context->preference('RecallsLog') ); |
461 |
return $self; |
461 |
return $self; |
462 |
} |
462 |
} |
463 |
|
463 |
|