Bug 17250: Do not retrieve marc subfield structure when the authorised value is not...
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 12 Oct 2016 12:48:09 +0000 (13:48 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 21 Oct 2016 15:21:27 +0000 (15:21 +0000)
GetAuthValCode did not return anything if the authorised_value column
was not defined. Our new calls to Koha::MarcSubfieldStructures->search
should behave the same

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

C4/Search.pm
catalogue/detail.pl
catalogue/itemsearch.pl
catalogue/moredetail.pl
circ/circulation.pl
tools/inventory.pl

index 2583f90..829d950 100644 (file)
@@ -1852,7 +1852,7 @@ sub searchResults {
     my $shelflocations =GetKohaAuthorisedValues('items.location','');
 
     # get notforloan authorised value list (see $shelflocations  FIXME)
-    my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan' });
+    my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan', authorised_value => { not => undef } });
     my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef;
 
     #Get itemtype hash
index b022c56..46387a9 100755 (executable)
@@ -195,16 +195,16 @@ my $copynumbers    = GetKohaAuthorisedValues('items.copynumber', $fw);
 my (@itemloop, @otheritemloop, %itemfields);
 my $norequests = 1;
 
-my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost' });
+my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => { not => undef } });
 if ( $mss->count ) {
     $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) );
 }
-$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged' });
+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => { not => undef } });
 if ( $mss->count ) {
     $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) );
 }
 
-$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials' });
+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => { not => undef } });
 my %materials_map;
 if ($mss->count) {
     my $materials_authvals = GetAuthorisedValues($mss->next->authorised_value);
index 001cf28..a2f0e41 100755 (executable)
@@ -88,10 +88,10 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user({
     flagsrequired   => { catalogue => 1 },
 });
 
-my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan' });
+my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan', authorised_value => { not => undef } });
 my $notforloan_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : [];
 
-$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.location' });
+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.location', authorised_value => { not => undef } });
 my $location_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : [];
 
 if (scalar keys %params > 0) {
@@ -264,7 +264,7 @@ if ($format eq 'html') {
         };
     }
 
-    my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.ccode' });
+    my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.ccode', authorised_value => { not => undef } });
     my $ccode_avcode = $mss->count ? $mss->next->authorised_value : 'CCODE';
     my $ccodes = GetAuthorisedValues($ccode_avcode);
     my @ccodes;
index b18d857..1a1adec 100755 (executable)
@@ -194,17 +194,17 @@ foreach my $item (@items){
 
 }
 
-my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost' });
+my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => { not => undef } });
 if ( $mss->count ) {
-    $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorisedvalue ) );
+    $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) );
 }
-$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged' });
+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => { not => undef } });
 if ( $mss->count ) {
-    $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorisedvalue ) );
+    $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) );
 }
-$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.withdrawn' });
+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.withdrawn', authorised_value => { not => undef } });
 if ( $mss->count ) {
-    $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorisedvalue) );
+    $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorised_value) );
 }
 
 $template->param(count => $data->{'count'},
index 787d501..1501433 100755 (executable)
@@ -341,8 +341,8 @@ if (@$barcodes) {
     #  Get the item title for more information
     my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode);
 
-    my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $getmessageiteminfo->{frameworkcode}, kohafield => 'items.notforloan' });
-    $template_params->{authvalcode_notforloan} = $mss->count ? $mss->next->authorisedvalue : undef;
+    my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $getmessageiteminfo->{frameworkcode}, kohafield => 'items.notforloan', authorised_value => { not => undef } });
+    $template_params->{authvalcode_notforloan} = $mss->count ? $mss->next->authorised_value : undef;
 
     # Fix for bug 7494: optional checkout-time fallback search for a book
 
index 1ad8116..ef59268 100755 (executable)
@@ -72,7 +72,7 @@ $frameworks->{''} = {frameworkcode => ''}; # Add the default framework
 
 for my $fwk (keys %$frameworks){
   my $fwkcode = $frameworks->{$fwk}->{'frameworkcode'};
-  my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fwkcode, kohafield => 'items.location' });
+  my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fwkcode, kohafield => 'items.location', authorised_value => { not => undef } });
   my $authcode = $mss->count ? $mss->next->authorised_value : undef;
     if ($authcode && $authorisedvalue_categories!~/\b$authcode\W/){
       $authorisedvalue_categories.="$authcode ";
@@ -88,7 +88,7 @@ my $statuses = [];
 for my $statfield (qw/items.notforloan items.itemlost items.withdrawn items.damaged/){
     my $hash = {};
     $hash->{fieldname} = $statfield;
-    my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => $statfield });
+    my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => $statfield, authorised_value => { not => undef } });
     $hash->{authcode} = $mss->count ? $mss->next->authorised_value : undef;
     if ($hash->{authcode}){
         my $arr = GetAuthorisedValues($hash->{authcode});