}
# hold_patron_id is NOT the barcode. It's the borrowernumber.
-# That's because the reserving patron may not have a barcode, or may be from an different system entirely (ILL)!
+# If a return triggers capture for a hold the borrowernumber is passed
+# and saved so that other hold info can be retrieved
sub hold_patron_id {
- my $self = shift or return;
- my $hold = $self->next_hold() or return;
- return $hold->{borrowernumber};
+ my $self = shift;
+ my $id = shift;
+ if ($id) {
+ $self->{hold}->{borrowernumber} = $id;
+ }
+ if ($self->{hold} ) {
+ return $self->{hold}->{borrowernumber};
+ }
+ return;
+
}
sub hold_patron_name {
my $self = shift or return;
- # return $self->{hold_patron_name} if $self->{hold_patron_name}; TODO: consider caching
my $borrowernumber = (@_ ? shift: $self->hold_patron_id()) or return;
my $holder = GetMember(borrowernumber=>$borrowernumber);
unless ($holder) {
"" ; # neither populated, empty string
my $name = $holder->{firstname} ? $holder->{firstname} . ' ' : '';
$name .= $holder->{surname} . $extra;
- # $self->{hold_patron_name} = $name; # TODO: consider caching
return $name;
}
}
sub destination_loc {
- my $self = shift or return;
- my $hold = $self->next_hold();
- return ($hold ? $hold->{branchcode} : '');
+ my $self = shift;
+ my $set_loc = shift;
+ if ($set_loc) {
+ $self->{dest_loc} = $set_loc;
+ }
+ if ($self->{dest_loc} ) {
+ return $self->{dest_loc};
+ }
+ return q{};
}
our $AUTOLOAD;
use ILS::Transaction;
use C4::Circulation;
+use C4::Reserves qw( ModReserveAffect );
use C4::Debug;
our @ISA = qw(ILS::Transaction);
}
if ($messages->{ResFound}) {
$self->hold($messages->{ResFound});
- $debug and warn "Item returned at $branch reserved at $messages->{ResFound}->{branchcode}";
- $self->alert_type(($branch eq $messages->{ResFound}->{branchcode}) ? '01' : '02');
+ if ($branch eq $messages->{ResFound}->{branchcode}) {
+ $self->alert_type('01');
+ ModReserveAffect( $messages->{ResFound}->{itemnumber},
+ $messages->{ResFound}->{borrowernumber}, 0);
+
+ } else {
+ $self->alert_type('02');
+ ModReserveAffect( $messages->{ResFound}->{itemnumber},
+ $messages->{ResFound}->{borrowernumber}, 1);
+
+ }
+ $self->{item}->hold_patron_id( $messages->{ResFound}->{borrowernumber} );
+ $self->{item}->destination_loc( $messages->{ResFound}->{branchcode} );
}
$self->alert(1) if defined $self->alert_type; # alert_type could be "00", hypothetically
$self->ok($return);
# apparently we can't trust the returns from Checkin yet (because C4::Circulation::AddReturn is faulty)
# So we reproduce the alert logic here.
if (not $status->alert) {
- if ($item->hold_patron_id) {
- $status->alert(1);
- if ($item->destination_loc and $item->destination_loc ne $current_loc) {
- $status->alert_type('02'); # hold at other library
- } else {
- $status->alert_type('01'); # hold at this library
- }
- } elsif ($item->destination_loc and $item->destination_loc ne $current_loc) {
+ if ($item->destination_loc and $item->destination_loc ne $current_loc) {
$status->alert(1);
$status->alert_type('04'); # no hold, just send it
}