- # It's ok to check it in if it exists, and if it was checked out
- $circ->ok($item && $item->{patron});
-
- if (!defined($item->{patron})) {
- $circ->screen_msg("Item not checked out");
- } else {
- if ($circ->ok) {
- $circ->patron($patron = new ILS::Patron $item->{patron});
- delete $item->{patron};
- delete $item->{due_date};
- $patron->{items} = [ grep {$_ ne $item_id} @{$patron->{items}} ];
- }
- }
+
+ # It's ok to check it in if it exists, and if it was checked out
+ # or it was not checked out but the checked_in_ok flag was set
+ $circ->ok( ( $checked_in_ok && $item ) || ( $item && $item->{patron} ) );
+ syslog("LOG_DEBUG", "C4::SIP::ILS::checkin - using checked_in_ok") if $checked_in_ok;
+
+ if ( !defined( $item->{patron} ) ) {
+ $circ->screen_msg("Item not checked out") unless $checked_in_ok;
+ syslog("LOG_DEBUG", "C4::SIP::ILS::checkin - item not checked out");
+ }
+ else {
+ if ( $circ->ok ) {
+ $circ->patron( $patron = C4::SIP::ILS::Patron->new( $item->{patron} ) );
+ delete $item->{patron};
+ delete $item->{due_date};
+ $patron->{items} = [ grep { $_ ne $item_id } @{ $patron->{items} } ];
+ }
+ }
+