@@ -, +, @@ in search results - Disable zebraqueue indexing (rebuild_zebra -z) - Perform a search - Choose a result with an item available for loan - Perform a checkout on this item - Re-perform a search - Test also with checkin --- C4/Search.pm | 53 ++++++++++++----------------------------------------- 1 file changed, 12 insertions(+), 41 deletions(-) --- a/C4/Search.pm +++ a/C4/Search.pm @@ -20,6 +20,7 @@ use strict; require Exporter; use C4::Context; use C4::Biblio; # GetMarcFromKohaField, GetBiblioData +use C4::Items; use C4::Koha; # getFacets use Lingua::Stem; use C4::Search::PazPar2; @@ -1933,11 +1934,11 @@ sub searchResults { } } - my $fw = $scan - ? undef - : $bibliotag < 10 - ? GetFrameworkCode($marcrecord->field($bibliotag)->data) - : GetFrameworkCode($marcrecord->subfield($bibliotag,$bibliosubf)); + my $biblionumber = + ( $bibliotag < 10 ) + ? $marcrecord->field($bibliotag)->data + : $marcrecord->subfield( $bibliotag, $bibliosubf ); + my $fw = $scan ? undef : GetFrameworkCode($biblionumber); SetUTF8Flag($marcrecord); my $oldbiblio = TransformMarcToKoha( $dbh, $marcrecord, $fw ); @@ -1961,7 +1962,6 @@ sub searchResults { # FIXME: is this used anywhere, I think it can be commented out? -- JF if ( $itemtypes{ $oldbiblio->{itemtype} }->{summary} ) { my $summary = $itemtypes{ $oldbiblio->{itemtype} }->{summary}; - my @fields = $marcrecord->fields(); my $newsummary; foreach my $line ( "$summary\n" =~ /(.*)\n/g ){ @@ -2003,34 +2003,10 @@ sub searchResults { } # Pull out the items fields - my @fields = $marcrecord->field($itemtag); - my $marcflavor = C4::Context->preference("marcflavour"); - # adding linked items that belong to host records - my $analyticsfield = '773'; - if ($marcflavor eq 'MARC21' || $marcflavor eq 'NORMARC') { - $analyticsfield = '773'; - } elsif ($marcflavor eq 'UNIMARC') { - $analyticsfield = '461'; - } - foreach my $hostfield ( $marcrecord->field($analyticsfield)) { - my $hostbiblionumber = $hostfield->subfield("0"); - my $linkeditemnumber = $hostfield->subfield("9"); - if(!$hostbiblionumber eq undef){ - my $hostbiblio = GetMarcBiblio($hostbiblionumber, 1); - my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostbiblionumber) ); - if(!$hostbiblio eq undef){ - my @hostitems = $hostbiblio->field($itemfield); - foreach my $hostitem (@hostitems){ - if ($hostitem->subfield("9") eq $linkeditemnumber){ - my $linkeditem =$hostitem; - # append linked items if they exist - if (!$linkeditem eq undef){ - push (@fields, $linkeditem);} - } - } - } - } - } + my @items = GetItemsInfo($biblionumber); + # adding items linked via host biblios + my @hostitems = GetHostItemsInfo($marcrecord); + push ( @items, @hostitems ); # Setting item statuses for display my @available_items_loop; @@ -2055,19 +2031,14 @@ sub searchResults { my $can_place_holds = 0; my $item_onhold_count = 0; my $notforloan_count = 0; - my $items_count = scalar(@fields); + my $items_count = scalar(@items); my $maxitems_pref = C4::Context->preference('maxItemsinSearchResults'); my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1; my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref # loop through every item - foreach my $field (@fields) { - my $item; + foreach my $item (@items) { - # populate the items hash - foreach my $code ( keys %subfieldstosearch ) { - $item->{$code} = $field->subfield( $subfieldstosearch{$code} ); - } $item->{description} = $itemtypes{ $item->{itype} }{description}; # OPAC hidden items --