Bug 13618: Specific for IntranetCirculationHomeHTML
[koha.git] / catalogue / detail.pl
index 704c595..1c6b234 100755 (executable)
@@ -30,7 +30,7 @@ use C4::Items;
 use C4::Circulation;
 use C4::Reserves;
 use C4::Serials;
-use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn);
+use C4::XISBN qw(get_xisbns);
 use C4::External::Amazon;
 use C4::Search;                # enabled_staff_search_views
 use C4::Tags qw(get_tags);
@@ -203,11 +203,11 @@ my $copynumbers =
 my (@itemloop, @otheritemloop, %itemfields);
 my $norequests = 1;
 
-my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => { not => undef } });
+my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
 if ( $mss->count ) {
     $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) );
 }
-$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => { not => undef } });
+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
 if ( $mss->count ) {
     $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) );
 }
@@ -216,7 +216,7 @@ if ( $mss->count ) {
     $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorised_value) );
 }
 
-$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => { not => undef } });
+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
 my %materials_map;
 if ($mss->count) {
     my $materials_authvals = GetAuthorisedValues($mss->next->authorised_value);
@@ -297,11 +297,15 @@ foreach my $item (@items) {
        $item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title};
     }
        
-    #count if item is used in analytical bibliorecords
-    my $countanalytics= GetAnalyticsCount($item->{itemnumber});
-    if ($countanalytics > 0){
-        $analytics_flag=1;
-        $item->{countanalytics} = $countanalytics;
+
+    if ( $analyze ) {
+        # count if item is used in analytical bibliorecords
+        # The 'countanalytics' flag is only used in the templates if analyze is set
+        my $countanalytics = C4::Context->preference('EasyAnalyticalRecords') ? GetAnalyticsCount($item->{itemnumber}) : 0;
+        if ($countanalytics > 0){
+            $analytics_flag=1;
+            $item->{countanalytics} = $countanalytics;
+        }
     }
 
     if (defined($item->{'materials'}) && $item->{'materials'} =~ /\S/){