2 # An object to handle checkin status
5 package C4::SIP::ILS::Transaction::Checkin;
10 # use POSIX qw(strftime);
12 use C4::SIP::ILS::Transaction;
15 use C4::Reserves qw( ModReserveAffect );
16 use C4::Items qw( ModItemTransfer );
19 use parent qw(C4::SIP::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;
49 my $return_date = shift;
53 my $barcode = $self->{item}->id;
55 $return_date = substr( $return_date, 0, 4 )
57 . substr( $return_date, 4, 2 )
59 . substr( $return_date, 6, 2 )
61 . substr( $return_date, 12, 2 )
63 . substr( $return_date, 14, 2 )
65 . substr( $return_date, 16, 2 );
67 $debug and warn "do_checkin() calling AddReturn($barcode, $branch)";
68 my ($return, $messages, $issue, $borrower) = AddReturn($barcode, $branch, undef, undef, $return_date);
70 # biblionumber, biblioitemnumber, itemnumber
71 # borrowernumber, reservedate, branchcode
72 # cancellationdate, found, reservenotes, priority, timestamp
73 if( $messages->{DataCorrupted} ) {
74 $self->alert_type('98');
76 if ($messages->{BadBarcode}) {
77 $self->alert_type('99');
79 if ($messages->{withdrawn}) {
80 $self->alert_type('99');
82 if ($messages->{Wrongbranch}) {
83 $self->{item}->destination_loc($messages->{Wrongbranch}->{Rightbranch});
84 $self->alert_type('04'); # send to other branch
86 if ($messages->{WrongTransfer}) {
87 $self->{item}->destination_loc($messages->{WrongTransfer});
88 $self->alert_type('04'); # send to other branch
90 if ($messages->{NeedsTransfer}) {
91 $self->{item}->destination_loc($messages->{NeedsTransfer});
92 $self->alert_type('04'); # send to other branch
94 if ($messages->{WasTransfered}) { # set into transit so tell unit
95 $self->{item}->destination_loc($issue->item->homebranch);
96 $self->alert_type('04'); # send to other branch
98 if ($messages->{ResFound}) {
99 $self->hold($messages->{ResFound});
100 if ($branch eq $messages->{ResFound}->{branchcode}) {
101 $self->alert_type('01');
102 ModReserveAffect( $messages->{ResFound}->{itemnumber},
103 $messages->{ResFound}->{borrowernumber}, 0, $messages->{ResFound}->{reserve_id});
106 $self->alert_type('02');
107 ModReserveAffect( $messages->{ResFound}->{itemnumber},
108 $messages->{ResFound}->{borrowernumber}, 1, $messages->{ResFound}->{reserve_id});
109 ModItemTransfer( $messages->{ResFound}->{itemnumber},
111 $messages->{ResFound}->{branchcode}
115 $self->{item}->hold_patron_id( $messages->{ResFound}->{borrowernumber} );
116 $self->{item}->destination_loc( $messages->{ResFound}->{branchcode} );
118 $self->alert(defined $self->alert_type); # alert_type could be "00", hypothetically
124 unless ($self->{item}) {
125 warn "resensitize(): no item found in object to resensitize";
128 return !$self->{item}->magnetic_media;
133 unless ($self->{patron}) {
134 warn "patron_id(): no patron found in object";
137 return $self->{patron}->id;