2 # An object to handle checkin status
5 package ILS::Transaction::Checkin;
10 # use POSIX qw(strftime);
16 use C4::Reserves qw( ModReserveAffect );
19 our @ISA = qw(ILS::Transaction);
24 collection_code => undef,
27 destination_loc => undef,
28 alert_type => undef, # 00,01,02,03,04 or 99
29 hold_patron_id => undef,
30 hold_patron_name => "",
36 my $self = $class->SUPER::new(); # start with an ILS::Transaction object
38 foreach (keys %fields) {
39 $self->{_permitted}->{$_} = $fields{$_}; # overlaying _permitted
42 @{$self}{keys %fields} = values %fields; # copying defaults into object
43 return bless $self, $class;
48 my $branch = @_ ? shift : 'SIP2' ;
49 my $barcode = $self->{item}->id;
50 $debug and warn "do_checkin() calling AddReturn($barcode, $branch)";
51 my ($return, $messages, $iteminformation, $borrower) = AddReturn($barcode, $branch);
52 $self->alert(!$return);
53 # ignoring messages: NotIssued, IsPermanent, WasLost, WasTransfered
55 # biblionumber, biblioitemnumber, itemnumber
56 # borrowernumber, reservedate, branchcode
57 # cancellationdate, found, reservenotes, priority, timestamp
59 if ($messages->{BadBarcode}) {
60 $self->alert_type('99');
62 if ($messages->{wthdrawn}) {
63 $self->alert_type('99');
65 if ($messages->{Wrongbranch}) {
66 $self->destination_loc($messages->{Wrongbranch}->{Rightbranch});
67 $self->alert_type('04'); # send to other branch
69 if ($messages->{WrongTransfer}) {
70 $self->destination_loc($messages->{WrongTransfer});
71 $self->alert_type('04'); # send to other branch
73 if ($messages->{NeedsTransfer}) {
74 $self->destination_loc($iteminformation->{homebranch});
75 $self->alert_type('04'); # send to other branch
77 if ($messages->{ResFound}) {
78 $self->hold($messages->{ResFound});
79 if ($branch eq $messages->{ResFound}->{branchcode}) {
80 $self->alert_type('01');
81 ModReserveAffect( $messages->{ResFound}->{itemnumber},
82 $messages->{ResFound}->{borrowernumber}, 0);
85 $self->alert_type('02');
86 ModReserveAffect( $messages->{ResFound}->{itemnumber},
87 $messages->{ResFound}->{borrowernumber}, 1);
90 $self->{item}->hold_patron_id( $messages->{ResFound}->{borrowernumber} );
91 $self->{item}->destination_loc( $messages->{ResFound}->{branchcode} );
93 $self->alert(1) if defined $self->alert_type; # alert_type could be "00", hypothetically
99 unless ($self->{item}) {
100 warn "resensitize(): no item found in object to resensitize";
103 return !$self->{item}->magnetic_media;
108 unless ($self->{patron}) {
109 warn "patron_id(): no patron found in object";
112 return $self->{patron}->id;