2 # An object to handle checkin status
5 package ILS
::Transaction
::Checkin
;
10 # use POSIX qw(strftime);
16 use C4
::Reserves
qw( ModReserveAffect );
17 use C4
::Items
qw( ModItemTransfer );
20 our @ISA = qw(ILS::Transaction);
25 collection_code
=> undef,
28 destination_loc
=> undef,
29 alert_type
=> undef, # 00,01,02,03,04 or 99
30 hold_patron_id
=> undef,
31 hold_patron_name
=> "",
37 my $self = $class->SUPER::new
(); # start with an ILS::Transaction object
39 foreach (keys %fields) {
40 $self->{_permitted
}->{$_} = $fields{$_}; # overlaying _permitted
43 @
{$self}{keys %fields} = values %fields; # copying defaults into object
44 return bless $self, $class;
53 my $barcode = $self->{item
}->id;
54 $debug and warn "do_checkin() calling AddReturn($barcode, $branch)";
55 my ($return, $messages, $iteminformation, $borrower) = AddReturn
($barcode, $branch);
56 $self->alert(!$return);
57 # ignoring messages: NotIssued, IsPermanent, WasLost, WasTransfered
59 # biblionumber, biblioitemnumber, itemnumber
60 # borrowernumber, reservedate, branchcode
61 # cancellationdate, found, reservenotes, priority, timestamp
63 if ($messages->{BadBarcode
}) {
64 $self->alert_type('99');
66 if ($messages->{wthdrawn
}) {
67 $self->alert_type('99');
69 if ($messages->{Wrongbranch
}) {
70 $self->destination_loc($messages->{Wrongbranch
}->{Rightbranch
});
71 $self->alert_type('04'); # send to other branch
73 if ($messages->{WrongTransfer
}) {
74 $self->destination_loc($messages->{WrongTransfer
});
75 $self->alert_type('04'); # send to other branch
77 if ($messages->{NeedsTransfer
}) {
78 $self->destination_loc($iteminformation->{homebranch
});
79 $self->alert_type('04'); # send to other branch
81 if ($messages->{ResFound
}) {
82 $self->hold($messages->{ResFound
});
83 if ($branch eq $messages->{ResFound
}->{branchcode
}) {
84 $self->alert_type('01');
85 ModReserveAffect
( $messages->{ResFound
}->{itemnumber
},
86 $messages->{ResFound
}->{borrowernumber
}, 0);
89 $self->alert_type('02');
90 ModReserveAffect
( $messages->{ResFound
}->{itemnumber
},
91 $messages->{ResFound
}->{borrowernumber
}, 1);
92 ModItemTransfer
( $messages->{ResFound
}->{itemnumber
},
94 $messages->{ResFound
}->{branchcode
}
98 $self->{item
}->hold_patron_id( $messages->{ResFound
}->{borrowernumber
} );
99 $self->{item
}->destination_loc( $messages->{ResFound
}->{branchcode
} );
101 $self->alert(1) if defined $self->alert_type; # alert_type could be "00", hypothetically
107 unless ($self->{item
}) {
108 warn "resensitize(): no item found in object to resensitize";
111 return !$self->{item
}->magnetic_media;
116 unless ($self->{patron
}) {
117 warn "patron_id(): no patron found in object";
120 return $self->{patron
}->id;