Merge remote-tracking branch 'origin/new/bug_7805'
[srvgit] / C4 / Search.pm
index c786080..b0085c4 100644 (file)
@@ -39,7 +39,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG);
 
 # set the version for version checking
 BEGIN {
-    $VERSION = 3.01;
+    $VERSION = 3.07.00.049;
     $DEBUG = ($ENV{DEBUG}) ? 1 : 0;
 }
 
@@ -287,7 +287,7 @@ sub SimpleSearch {
 ( undef, $results_hashref, \@facets_loop ) = getRecords (
 
         $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
-        $results_per_page, $offset,       $expanded_facet, $branches,
+        $results_per_page, $offset,       $expanded_facet, $branches,$itemtypes,
         $query_type,       $scan
     );
 
@@ -301,7 +301,7 @@ See verbse embedded documentation.
 sub getRecords {
     my (
         $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
-        $results_per_page, $offset,       $expanded_facet, $branches,
+        $results_per_page, $offset,       $expanded_facet, $branches,$itemtypes,
         $query_type,       $scan
     ) = @_;
 
@@ -555,6 +555,17 @@ sub getRecords {
                                                                        $facet_label_value = "*";
                                                                }
                             }
+                            # if it's a itemtype, label by the name, not the code,
+                            if ( $link_value =~ /itype/ ) {
+                                if (defined $itemtypes
+                                    && ref($itemtypes) eq "HASH"
+                                    && defined $itemtypes->{$one_facet}
+                                    && ref ($itemtypes->{$one_facet}) eq "HASH")
+                                {
+                                    $facet_label_value =
+                                        $itemtypes->{$one_facet}->{'description'};
+                                }
+                            }
 
                             # but we're down with the whole label being in the link's title.
                             push @this_facets_array, {
@@ -721,7 +732,7 @@ sub _detect_truncation {
 sub _build_stemmed_operand {
     my ($operand,$lang) = @_;
     require Lingua::Stem::Snowball ;
-    my $stemmed_operand;
+    my $stemmed_operand=q{};
 
     # If operand contains a digit, it is almost certainly an identifier, and should
     # not be stemmed.  This is particularly relevant for ISBNs and ISSNs, which
@@ -1458,12 +1469,7 @@ sub searchResults {
     }
 
     #search item field code
-    my $sth =
-      $dbh->prepare(
-"SELECT tagfield FROM marc_subfield_structure WHERE kohafield LIKE 'items.itemnumber'"
-      );
-    $sth->execute;
-    my ($itemtag) = $sth->fetchrow;
+    my ($itemtag, undef) = &GetMarcFromKohaField( "items.itemnumber", "" );
 
     ## find column names of items related to MARC
     my $sth2 = $dbh->prepare("SHOW COLUMNS FROM items");
@@ -1781,7 +1787,7 @@ sub searchResults {
         # XSLT processing of some stuff
        use C4::Charset;
        SetUTF8Flag($marcrecord);
-       $debug && warn $marcrecord->as_formatted;
+        warn $marcrecord->as_formatted if $DEBUG;
        my $interface = $search_context eq 'opac' ? 'OPAC' : '';
        if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) {
             $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $interface."XSLTResultsDisplay", 1, \@hiddenitems);
@@ -1812,8 +1818,6 @@ sub searchResults {
         $oldbiblio->{intransitcount}       = $item_in_transit_count;
         $oldbiblio->{onholdcount}          = $item_onhold_count;
         $oldbiblio->{orderedcount}         = $ordered_count;
-        # deleting - in isbn to enable amazon content
-        $oldbiblio->{isbn} =~ s/-//g;
 
         if (C4::Context->preference("AlternateHoldingsField") && $items_count == 0) {
             my $fieldspec = C4::Context->preference("AlternateHoldingsField");