View | Details | Raw Unified | Return to bug 15054
Collapse All | Expand All

(-)a/C4/Search.pm (-42 / +12 lines)
Lines 20-25 use strict; Link Here
20
require Exporter;
20
require Exporter;
21
use C4::Context;
21
use C4::Context;
22
use C4::Biblio;    # GetMarcFromKohaField, GetBiblioData
22
use C4::Biblio;    # GetMarcFromKohaField, GetBiblioData
23
use C4::Items;
23
use C4::Koha;      # getFacets
24
use C4::Koha;      # getFacets
24
use Lingua::Stem;
25
use Lingua::Stem;
25
use C4::Search::PazPar2;
26
use C4::Search::PazPar2;
Lines 1933-1943 sub searchResults { Link Here
1933
            }
1934
            }
1934
        }
1935
        }
1935
1936
1936
        my $fw = $scan
1937
        my $biblionumber =
1937
             ? undef
1938
          ( $bibliotag < 10 )
1938
             : $bibliotag < 10
1939
          ? $marcrecord->field($bibliotag)->data
1939
               ? GetFrameworkCode($marcrecord->field($bibliotag)->data)
1940
          : $marcrecord->subfield( $bibliotag, $bibliosubf );
1940
               : GetFrameworkCode($marcrecord->subfield($bibliotag,$bibliosubf));
1941
        my $fw = $scan ? undef : GetFrameworkCode($biblionumber);
1941
1942
1942
        SetUTF8Flag($marcrecord);
1943
        SetUTF8Flag($marcrecord);
1943
        my $oldbiblio = TransformMarcToKoha( $dbh, $marcrecord, $fw );
1944
        my $oldbiblio = TransformMarcToKoha( $dbh, $marcrecord, $fw );
Lines 1961-1967 sub searchResults { Link Here
1961
 # FIXME: is this used anywhere, I think it can be commented out? -- JF
1962
 # FIXME: is this used anywhere, I think it can be commented out? -- JF
1962
        if ( $itemtypes{ $oldbiblio->{itemtype} }->{summary} ) {
1963
        if ( $itemtypes{ $oldbiblio->{itemtype} }->{summary} ) {
1963
            my $summary = $itemtypes{ $oldbiblio->{itemtype} }->{summary};
1964
            my $summary = $itemtypes{ $oldbiblio->{itemtype} }->{summary};
1964
            my @fields  = $marcrecord->fields();
1965
1965
1966
            my $newsummary;
1966
            my $newsummary;
1967
            foreach my $line ( "$summary\n" =~ /(.*)\n/g ){
1967
            foreach my $line ( "$summary\n" =~ /(.*)\n/g ){
Lines 2003-2036 sub searchResults { Link Here
2003
        }
2003
        }
2004
2004
2005
        # Pull out the items fields
2005
        # Pull out the items fields
2006
        my @fields = $marcrecord->field($itemtag);
2006
        my @items = GetItemsInfo($biblionumber);
2007
        my $marcflavor = C4::Context->preference("marcflavour");
2007
        # adding items linked via host biblios
2008
        # adding linked items that belong to host records
2008
        my @hostitems = GetHostItemsInfo($marcrecord);
2009
        my $analyticsfield = '773';
2009
        push ( @items, @hostitems );
2010
        if ($marcflavor eq 'MARC21' || $marcflavor eq 'NORMARC') {
2011
            $analyticsfield = '773';
2012
        } elsif ($marcflavor eq 'UNIMARC') {
2013
            $analyticsfield = '461';
2014
        }
2015
        foreach my $hostfield ( $marcrecord->field($analyticsfield)) {
2016
            my $hostbiblionumber = $hostfield->subfield("0");
2017
            my $linkeditemnumber = $hostfield->subfield("9");
2018
            if(!$hostbiblionumber eq undef){
2019
                my $hostbiblio = GetMarcBiblio($hostbiblionumber, 1);
2020
                my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostbiblionumber) );
2021
                if(!$hostbiblio eq undef){
2022
                    my @hostitems = $hostbiblio->field($itemfield);
2023
                    foreach my $hostitem (@hostitems){
2024
                        if ($hostitem->subfield("9") eq $linkeditemnumber){
2025
                            my $linkeditem =$hostitem;
2026
                            # append linked items if they exist
2027
                            if (!$linkeditem eq undef){
2028
                                push (@fields, $linkeditem);}
2029
                        }
2030
                    }
2031
                }
2032
            }
2033
        }
2034
2010
2035
        # Setting item statuses for display
2011
        # Setting item statuses for display
2036
        my @available_items_loop;
2012
        my @available_items_loop;
Lines 2055-2073 sub searchResults { Link Here
2055
        my $can_place_holds       = 0;
2031
        my $can_place_holds       = 0;
2056
        my $item_onhold_count     = 0;
2032
        my $item_onhold_count     = 0;
2057
        my $notforloan_count      = 0;
2033
        my $notforloan_count      = 0;
2058
        my $items_count           = scalar(@fields);
2034
        my $items_count           = scalar(@items);
2059
        my $maxitems_pref = C4::Context->preference('maxItemsinSearchResults');
2035
        my $maxitems_pref = C4::Context->preference('maxItemsinSearchResults');
2060
        my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1;
2036
        my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1;
2061
        my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref
2037
        my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref
2062
2038
2063
        # loop through every item
2039
        # loop through every item
2064
        foreach my $field (@fields) {
2040
        foreach my $item (@items) {
2065
            my $item;
2066
2041
2067
            # populate the items hash
2068
            foreach my $code ( keys %subfieldstosearch ) {
2069
                $item->{$code} = $field->subfield( $subfieldstosearch{$code} );
2070
            }
2071
            $item->{description} = $itemtypes{ $item->{itype} }{description};
2042
            $item->{description} = $itemtypes{ $item->{itype} }{description};
2072
2043
2073
	        # OPAC hidden items
2044
	        # OPAC hidden items
2074
- 

Return to bug 15054