2 # An object to handle checkin status
5 package ILS::Transaction::Checkin;
10 # use POSIX qw(strftime);
18 our @ISA = qw(ILS::Transaction);
23 collection_code => undef,
26 destination_loc => undef,
27 alert_type => undef, # 00,01,02,03,04 or 99
28 hold_patron_id => undef,
29 hold_patron_name => "",
35 my $self = $class->SUPER::new(); # start with an ILS::Transaction object
37 foreach (keys %fields) {
38 $self->{_permitted}->{$_} = $fields{$_}; # overlaying _permitted
41 @{$self}{keys %fields} = values %fields; # copying defaults into object
42 return bless $self, $class;
47 my $branch = @_ ? shift : 'SIP2' ;
48 my $barcode = $self->{item}->id;
49 $debug and warn "do_checkin() calling AddReturn($barcode, $branch)";
50 my ($return, $messages, $iteminformation, $borrower) = AddReturn($barcode, $branch);
51 $self->alert(!$return);
52 # ignoring messages: NotIssued, IsPermanent, WasLost, WasTransfered
54 # biblionumber, biblioitemnumber, itemnumber
55 # borrowernumber, reservedate, branchcode
56 # cancellationdate, found, reservenotes, priority, timestamp
58 if ($messages->{BadBarcode}) {
59 $self->alert_type('99');
61 if ($messages->{wthdrawn}) {
62 $self->alert_type('99');
64 if ($messages->{Wrongbranch}) {
65 $self->destination_loc($messages->{Wrongbranch}->{Rightbranch});
66 $self->alert_type('04'); # send to other branch
68 if ($messages->{WrongTransfer}) {
69 $self->destination_loc($messages->{WrongTransfer});
70 $self->alert_type('04'); # send to other branch
72 if ($messages->{NeedsTransfer}) {
73 $self->destination_loc($iteminformation->{homebranch});
74 $self->alert_type('04'); # send to other branch
76 if ($messages->{ResFound}) {
77 $self->hold($messages->{ResFound});
78 $debug and warn "Item returned at $branch reserved at $messages->{ResFound}->{branchcode}";
79 $self->alert_type(($branch eq $messages->{ResFound}->{branchcode}) ? '01' : '02');
81 $self->alert(1) if defined $self->alert_type; # alert_type could be "00", hypothetically
87 unless ($self->{item}) {
88 warn "resensitize(): no item found in object to resensitize";
91 return !$self->{item}->magnetic_media;
96 unless ($self->{patron}) {
97 warn "patron_id(): no patron found in object";
100 return $self->{patron}->id;