- $return_date = substr( $return_date, 0, 4 )
- . '-'
- . substr( $return_date, 4, 2 )
- . '-'
- . substr( $return_date, 6, 2 )
- . q{ }
- . substr( $return_date, 12, 2 )
- . ':'
- . substr( $return_date, 14, 2 )
- . ':'
- . substr( $return_date, 16, 2 );
-
- $debug and warn "do_checkin() calling AddReturn($barcode, $branch)";
- my ($return, $messages, $iteminformation, $borrower) = AddReturn($barcode, $branch, undef, undef, $return_date);
- $self->alert(!$return);
- # ignoring messages: NotIssued, IsPermanent, WasLost, WasTransfered
+ if ( $return_date ) {
+ $return_date = substr( $return_date, 0, 4 )
+ . '-'
+ . substr( $return_date, 4, 2 )
+ . '-'
+ . substr( $return_date, 6, 2 )
+ . q{ }
+ . substr( $return_date, 12, 2 )
+ . ':'
+ . substr( $return_date, 14, 2 )
+ . ':'
+ . substr( $return_date, 16, 2 );
+ $return_date = dt_from_string($return_date);
+ }
+
+ my ( $return, $messages, $issue, $borrower );
+
+ my $item = Koha::Items->find( { barcode => $barcode } );
+
+ my $human_required = 0;
+ if ( C4::Context->preference("CircConfirmItemParts")
+ && defined($item)
+ && $item->materials )
+ {
+ $human_required = 1;
+ $messages->{additional_materials} = 1;
+ }
+
+ my $checkin_blocked_by_holds = $holds_block_checkin && $item->biblio->holds->count;
+
+ ( $return, $messages, $issue, $borrower ) =
+ AddReturn( $barcode, $branch, undef, $return_date )
+ unless $human_required || $checkin_blocked_by_holds;
+
+ if ( $checked_in_ok ) {
+ delete $messages->{ItemLocationUpdated};
+ delete $messages->{NotIssued};
+ delete $messages->{LocalUse};
+ $return = 1 unless keys %$messages;
+ }