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, $iteminformation, $borrower) = AddReturn
($barcode, $branch, undef, undef, $return_date);
69 $self->alert(!$return);
70 # ignoring messages: NotIssued, IsPermanent, WasLost, WasTransfered
72 # biblionumber, biblioitemnumber, itemnumber
73 # borrowernumber, reservedate, branchcode
74 # cancellationdate, found, reservenotes, priority, timestamp
76 if ($messages->{BadBarcode
}) {
77 $self->alert_type('99');
79 if ($messages->{withdrawn
}) {
80 $self->alert_type('99');
82 if ($messages->{Wrongbranch
}) {
83 $self->destination_loc($messages->{Wrongbranch
}->{Rightbranch
});
84 $self->alert_type('04'); # send to other branch
86 if ($messages->{WrongTransfer
}) {
87 $self->destination_loc($messages->{WrongTransfer
});
88 $self->alert_type('04'); # send to other branch
90 if ($messages->{NeedsTransfer
}) {
91 $self->destination_loc($iteminformation->{homebranch
});
92 $self->alert_type('04'); # send to other branch
94 if ($messages->{ResFound
}) {
95 $self->hold($messages->{ResFound
});
96 if ($branch eq $messages->{ResFound
}->{branchcode
}) {
97 $self->alert_type('01');
98 ModReserveAffect
( $messages->{ResFound
}->{itemnumber
},
99 $messages->{ResFound
}->{borrowernumber
}, 0);
102 $self->alert_type('02');
103 ModReserveAffect
( $messages->{ResFound
}->{itemnumber
},
104 $messages->{ResFound
}->{borrowernumber
}, 1);
105 ModItemTransfer
( $messages->{ResFound
}->{itemnumber
},
107 $messages->{ResFound
}->{branchcode
}
111 $self->{item
}->hold_patron_id( $messages->{ResFound
}->{borrowernumber
} );
112 $self->{item
}->destination_loc( $messages->{ResFound
}->{branchcode
} );
114 $self->alert(1) if defined $self->alert_type; # alert_type could be "00", hypothetically
120 unless ($self->{item
}) {
121 warn "resensitize(): no item found in object to resensitize";
124 return !$self->{item
}->magnetic_media;
129 unless ($self->{patron
}) {
130 warn "patron_id(): no patron found in object";
133 return $self->{patron
}->id;