| 
      
            Lines 1582-1587
          Format results in a form suitable for passing to the template
      
      
        Link Here
      
     | 
  
        
          | 1582 | 
          sub searchResults { | 
          1582 | 
          sub searchResults { | 
        
        
          | 1583 | 
              my ( $search_context, $searchdesc, $hits, $results_per_page, $offset, $scan, $marcresults ) = @_;  | 
          1583 | 
              my ( $search_context, $searchdesc, $hits, $results_per_page, $offset, $scan, $marcresults ) = @_;  | 
        
        
          | 1584 | 
              my $dbh = C4::Context->dbh;  | 
          1584 | 
              my $dbh = C4::Context->dbh;  | 
        
            
               | 
               | 
              1585 | 
                  my $marcflavour = C4::Context->preference("marcflavour"); | 
            
        
          | 1585 | 
              my @newresults;  | 
          1586 | 
              my @newresults;  | 
        
        
          | 1586 | 
           | 
          1587 | 
           | 
        
        
          | 1587 | 
              require C4::Items;  | 
          1588 | 
              require C4::Items;  | 
        
  
    | 
      
            Lines 1646-1652
          sub searchResults {
      
      
        Link Here
      
     | 
  
        
          | 1646 | 
                  $times = $hits;	 # FIXME: if $hits is undefined, why do we want to equal it?  | 
          1647 | 
                  $times = $hits;	 # FIXME: if $hits is undefined, why do we want to equal it?  | 
        
        
          | 1647 | 
              }  | 
          1648 | 
              }  | 
        
        
          | 1648 | 
           | 
          1649 | 
           | 
        
            
              | 1649 | 
              	my $marcflavour = C4::Context->preference("marcflavour"); | 
               | 
               | 
            
        
          | 1650 | 
              # We get the biblionumber position in MARC  | 
          1650 | 
              # We get the biblionumber position in MARC  | 
        
        
          | 1651 | 
              my ($bibliotag,$bibliosubf)=GetMarcFromKohaField('biblio.biblionumber',''); | 
          1651 | 
              my ($bibliotag,$bibliosubf)=GetMarcFromKohaField('biblio.biblionumber',''); | 
        
        
          | 1652 | 
           | 
          1652 | 
           | 
        
  
    | 
      
            Lines 1727-1754
          sub searchResults {
      
      
        Link Here
      
     | 
  
        
          | 1727 | 
           | 
          1727 | 
           | 
        
        
          | 1728 | 
                  # Pull out the items fields  | 
          1728 | 
                  # Pull out the items fields  | 
        
        
          | 1729 | 
                  my @fields = $marcrecord->field($itemtag);  | 
          1729 | 
                  my @fields = $marcrecord->field($itemtag);  | 
        
          
            
              | 1730 | 
                      my $marcflavor = C4::Context->preference("marcflavour"); | 
              1730 | 
               | 
            
            
              | 1731 | 
                      # adding linked items that belong to host records  | 
              1731 | 
                      if ( C4::Context->preference('EasyAnalyticalRecords') ) { | 
            
            
              | 1732 | 
                      my $analyticsfield = '773';  | 
              1732 | 
                          # adding linked items that belong to host records  | 
            
            
              | 1733 | 
                      if ($marcflavor eq 'MARC21' || $marcflavor eq 'NORMARC') { | 
              1733 | 
                          my $analyticsfield = '773';  | 
            
            
              | 1734 | 
                          $analyticsfield = '773';  | 
              1734 | 
                          if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC') { | 
            
            
              | 1735 | 
                      } elsif ($marcflavor eq 'UNIMARC') { | 
              1735 | 
                              $analyticsfield = '773';  | 
            
            
              | 1736 | 
                          $analyticsfield = '461';  | 
              1736 | 
                          } elsif ($marcflavour eq 'UNIMARC') { | 
            
            
              | 1737 | 
                      }  | 
              1737 | 
                              $analyticsfield = '461';  | 
            
            
              | 1738 | 
                      foreach my $hostfield ( $marcrecord->field($analyticsfield)) { | 
              1738 | 
                          }  | 
            
            
              | 1739 | 
                          my $hostbiblionumber = $hostfield->subfield("0"); | 
              1739 | 
                          foreach my $hostfield ( $marcrecord->field($analyticsfield) ) { | 
            
            
              | 1740 | 
                          my $linkeditemnumber = $hostfield->subfield("9"); | 
              1740 | 
                              my $hostbiblionumber = $hostfield->subfield("0"); | 
            
            
              | 1741 | 
                          if(!$hostbiblionumber eq undef){ | 
              1741 | 
                              my $linkeditemnumber = $hostfield->subfield("9"); | 
            
            
              | 1742 | 
                              my $hostbiblio = GetMarcBiblio($hostbiblionumber, 1);  | 
              1742 | 
                              if ( $hostbiblionumber && $linkeditemnumber ) { | 
            
            
              | 1743 | 
                              my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostbiblionumber) );  | 
              1743 | 
                                  my $hostbiblio = GetMarcBiblio($hostbiblionumber, 1);  | 
            
            
              | 1744 | 
                              if(!$hostbiblio eq undef){ | 
              1744 | 
                                  my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostbiblionumber) );  | 
            
            
              | 1745 | 
                                  my @hostitems = $hostbiblio->field($itemfield);  | 
              1745 | 
                                  if ( $hostbiblio ){ | 
            
            
              | 1746 | 
                                  foreach my $hostitem (@hostitems){ | 
              1746 | 
                                      my @hostitems = $hostbiblio->field($itemfield);  | 
            
            
              | 1747 | 
                                      if ($hostitem->subfield("9") eq $linkeditemnumber){ | 
              1747 | 
                                      foreach my $hostitem (@hostitems){ | 
            
            
              | 1748 | 
                                          my $linkeditem =$hostitem;  | 
              1748 | 
                                          if ( $hostitem->subfield("9") eq $linkeditemnumber ){ | 
            
            
              | 1749 | 
                                          # append linked items if they exist  | 
              1749 | 
                                              my $linkeditem = $hostitem;  | 
            
            
              | 1750 | 
                                          if (!$linkeditem eq undef){ | 
              1750 | 
                                              # append linked items if they exist  | 
            
            
              | 1751 | 
                                              push (@fields, $linkeditem);}  | 
              1751 | 
                                              if ($linkeditem) { | 
            
            
               | 
               | 
              1752 | 
                                                  push (@fields, $linkeditem);  | 
            
            
              | 1753 | 
                                              }  | 
            
            
              | 1754 | 
                                          }  | 
            
        
          | 1752 | 
                                  }  | 
          1755 | 
                                  }  | 
        
        
          | 1753 | 
                              }  | 
          1756 | 
                              }  | 
        
        
          | 1754 | 
                          }  | 
          1757 | 
                          }  |