-sub null_to_zzempty ($) {
- my $string = shift;
- defined($string) or return 'zzEMPTY';
- ($string eq "NULL") and return 'zzEMPTY';
- return $string; # else return the valid value
-}
-sub display_value{
- my ($crit,$value)=@_;
- my $display_value =
- ($crit =~ /ccode/ ) ? $ccodes->{$value} :
- ($crit =~ /location/) ? $locations->{$value} :
- ($crit =~ /itemtype/) ? $itemtypes->{$value}->{description} :
- ($crit =~ /branch/) ? GetBranchName($value):
- ($crit =~ /reservestatus/) ? reservestatushuman($value):
- $value; # default fallback
- if ($crit =~ /(sort1|sort2)/) {
- $display_value=GetAuthorisedValues("B$_",$value);
- } elsif ($crit =~ /category/) {
- my $element=any{$value eq $_->{categorycode}} @$categoryloop;
- $display_value=$$element{description};
- }
- return $display_value;
+sub display_value {
+ my ( $crit, $value ) = @_;
+ my $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
+ my $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
+ my $Bsort1 = GetAuthorisedValues("Bsort1");
+ my $Bsort2 = GetAuthorisedValues("Bsort2");
+ my $display_value =
+ ( $crit =~ /ccode/ ) ? $ccodes->{$value}
+ : ( $crit =~ /location/ ) ? $locations->{$value}
+ : ( $crit =~ /itemtype/ ) ? Koha::ItemTypes->find( $value )->translated_description
+ : ( $crit =~ /branch/ ) ? Koha::Libraries->find($value)->branchname
+ : ( $crit =~ /reservestatus/ ) ? reservestatushuman($value)
+ : $value; # default fallback
+ if ($crit =~ /sort1/) {
+ foreach (@$Bsort1) {
+ ($value eq $_->{authorised_value}) or next;
+ $display_value = $_->{lib} and last;
+ }
+ }
+ elsif ($crit =~ /sort2/) {
+ foreach (@$Bsort2) {
+ ($value eq $_->{authorised_value}) or next;
+ $display_value = $_->{lib} and last;
+ }
+ }
+ elsif ( $crit =~ /category/ ) {
+ my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
+ foreach my $patron_category ( @patron_categories ) {
+ ( $value eq $patron_category->categorycode ) or next;
+ $display_value = $patron_category->description and last;
+ }
+ }
+ return $display_value;