+ # Get the item title for more information
+ my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode);
+ $template->param(
+ authvalcode_notforloan => C4::Koha::GetAuthValCode('items.notforloan', $getmessageiteminfo->{'frameworkcode'}),
+ );
+ # Fix for bug 7494: optional checkout-time fallback search for a book
+
+ if ( $error->{'UNKNOWN_BARCODE'}
+ && C4::Context->preference("itemBarcodeFallbackSearch") )
+ {
+ $template->param( FALLBACK => 1 );
+
+ my $query = "kw=" . $barcode;
+ my ( $searcherror, $results, $total_hits ) = SimpleSearch($query);
+
+ # if multiple hits, offer options to librarian
+ if ( $total_hits > 0 ) {
+ my @options = ();
+ foreach my $hit ( @{$results} ) {
+ my $chosen =
+ TransformMarcToKoha( C4::Context->dbh,
+ MARC::Record->new_from_usmarc($hit) );
+
+ # offer all barcodes individually
+ foreach my $barcode ( sort split(/\s*\|\s*/, $chosen->{barcode}) ) {
+ my %chosen_single = %{$chosen};
+ $chosen_single{barcode} = $barcode;
+ push( @options, \%chosen_single );
+ }
+ }
+ $template->param( options => \@options );
+ }
+ }
+