View | Details | Raw Unified | Return to bug 17642
Collapse All | Expand All

(-)a/C4/Search.pm (-1 / +1 lines)
Lines 1850-1856 sub searchResults { Link Here
1850
# though it is possible to have different authvals for different fws.
1850
# though it is possible to have different authvals for different fws.
1851
1851
1852
    my $shelflocations =
1852
    my $shelflocations =
1853
      { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
1853
      { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
1854
1854
1855
    # get notforloan authorised value list (see $shelflocations  FIXME)
1855
    # get notforloan authorised value list (see $shelflocations  FIXME)
1856
    my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan', authorised_value => { not => undef } });
1856
    my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan', authorised_value => { not => undef } });
(-)a/C4/XSLT.pm (-2 / +2 lines)
Lines 274-282 sub buildKohaItemsNamespace { Link Here
274
    }
274
    }
275
275
276
    my $shelflocations =
276
    my $shelflocations =
277
      { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => GetFrameworkCode($biblionumber), kohafield => 'items.location' } ) };
277
      { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => GetFrameworkCode($biblionumber), kohafield => 'items.location' } ) };
278
    my $ccodes =
278
    my $ccodes =
279
      { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => GetFrameworkCode($biblionumber), kohafield => 'items.ccode' } ) };
279
      { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => GetFrameworkCode($biblionumber), kohafield => 'items.ccode' } ) };
280
280
281
    my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' });
281
    my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' });
282
282
(-)a/Koha/AuthorisedValues.pm (+22 lines)
Lines 139-144 sub get_description_by_koha_field { Link Here
139
    return $descriptions;
139
    return $descriptions;
140
}
140
}
141
141
142
sub get_descriptions_by_koha_field {
143
    my ( $self, $params ) = @_;
144
    my $frameworkcode = $params->{frameworkcode} || '';
145
    my $kohafield = $params->{kohafield};
146
147
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance;
148
    my $cache_key    = "AV_descriptions:$frameworkcode:$kohafield";
149
    my $cached       = $memory_cache->get_from_cache($cache_key);
150
    return @$cached if $cached;
151
152
    my @avs          = $self->search_by_koha_field($params);
153
    my @descriptions = map {
154
        {
155
            authorised_value => $_->authorised_value,
156
            lib              => $_->lib,
157
            opac_description => $_->opac_description
158
        }
159
    } @avs;
160
    $memory_cache->set_in_cache( $cache_key, \@descriptions );
161
    return @descriptions;
162
}
163
142
sub categories {
164
sub categories {
143
    my ( $self ) = @_;
165
    my ( $self ) = @_;
144
    my $rs = $self->_resultset->search(
166
    my $rs = $self->_resultset->search(
(-)a/basket/basket.pl (-1 / +1 lines)
Lines 77-83 foreach my $biblionumber ( @bibs ) { Link Here
77
    }
77
    }
78
	
78
	
79
    my $shelflocations =
79
    my $shelflocations =
80
      { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
80
      { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
81
81
82
	for my $itm (@items) {
82
	for my $itm (@items) {
83
	    if ($itm->{'location'}){
83
	    if ($itm->{'location'}){
(-)a/catalogue/detail.pl (-3 / +3 lines)
Lines 190-200 $dat->{'showncount'} = scalar @items + @hostitems; Link Here
190
$dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items;
190
$dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items;
191
191
192
my $shelflocations =
192
my $shelflocations =
193
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) };
193
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) };
194
my $collections =
194
my $collections =
195
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
195
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
196
my $copynumbers =
196
my $copynumbers =
197
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
197
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
198
my (@itemloop, @otheritemloop, %itemfields);
198
my (@itemloop, @otheritemloop, %itemfields);
199
my $norequests = 1;
199
my $norequests = 1;
200
200
(-)a/catalogue/moredetail.pl (-2 / +2 lines)
Lines 120-128 $data->{'showncount'}=$showncount; Link Here
120
$data->{'hiddencount'}=$hiddencount;  # can be zero
120
$data->{'hiddencount'}=$hiddencount;  # can be zero
121
121
122
my $ccodes =
122
my $ccodes =
123
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
123
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
124
my $copynumbers =
124
my $copynumbers =
125
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
125
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
126
my $itemtypes = GetItemTypes;
126
my $itemtypes = GetItemTypes;
127
127
128
$data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'translated_description'};
128
$data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'translated_description'};
(-)a/circ/returns.pl (-1 / +1 lines)
Lines 552-558 my $returned_counter = ( C4::Context->preference('numReturnedItemsToShow') ) ? C Link Here
552
my $count = 0;
552
my $count = 0;
553
my @riloop;
553
my @riloop;
554
my $shelflocations =
554
my $shelflocations =
555
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
555
  { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
556
foreach ( sort { $a <=> $b } keys %returneditems ) {
556
foreach ( sort { $a <=> $b } keys %returneditems ) {
557
    my %ri;
557
    my %ri;
558
    if ( $count++ < $returned_counter ) {
558
    if ( $count++ < $returned_counter ) {
(-)a/opac/opac-basket.pl (-2 / +2 lines)
Lines 86-94 foreach my $biblionumber ( @bibs ) { Link Here
86
      $hasauthors = 1;
86
      $hasauthors = 1;
87
    }
87
    }
88
    my $collections =
88
    my $collections =
89
      { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.ccode' } ) };
89
      { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.ccode' } ) };
90
    my $shelflocations =
90
    my $shelflocations =
91
      { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
91
      { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
92
92
93
	# COinS format FIXME: for books Only
93
	# COinS format FIXME: for books Only
94
        my $coins_format;
94
        my $coins_format;
(-)a/opac/opac-detail.pl (-3 / +3 lines)
Lines 546-556 if ( $itemtype ) { Link Here
546
}
546
}
547
547
548
my $shelflocations =
548
my $shelflocations =
549
  { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
549
  { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
550
my $collections =
550
my $collections =
551
  { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.ccode' } ) };
551
  { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.ccode' } ) };
552
my $copynumbers =
552
my $copynumbers =
553
  { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.copynumber' } ) };
553
  { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.copynumber' } ) };
554
554
555
#coping with subscriptions
555
#coping with subscriptions
556
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
556
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
(-)a/reports/catalogue_stats.pl (-4 / +4 lines)
Lines 122-129 if ($do_it) { Link Here
122
122
123
    my $itemtypes = GetItemTypes( style => 'array' );
123
    my $itemtypes = GetItemTypes( style => 'array' );
124
124
125
    my @authvals = map { { code => $_->authorised_value, description => $_->lib } } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } );
125
    my @authvals = map { { code => $_->{authorised_value}, description => $_->{lib} } } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } );
126
    my @locations = map { { code => $_->authorised_value, description => $_->lib } } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } );
126
    my @locations = map { { code => $_->{authorised_value}, description => $_->{lib} } } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } );
127
127
128
    foreach my $kohafield (qw(items.notforloan items.materials)) {
128
    foreach my $kohafield (qw(items.notforloan items.materials)) {
129
        my $subfield_structure = GetMarcSubfieldStructureFromKohaField($kohafield);
129
        my $subfield_structure = GetMarcSubfieldStructureFromKohaField($kohafield);
Lines 314-320 sub calculate { Link Here
314
    } else {
314
    } else {
315
        $sth->execute();
315
        $sth->execute();
316
    }
316
    }
317
    my $rowauthvals = { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => $origline } ) };
317
    my $rowauthvals = { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => $origline } ) };
318
    while ( my ($celvalue) = $sth->fetchrow ) {
318
    while ( my ($celvalue) = $sth->fetchrow ) {
319
        my %cell;
319
        my %cell;
320
        if (defined $celvalue and $celvalue ne '') {
320
        if (defined $celvalue and $celvalue ne '') {
Lines 377-383 sub calculate { Link Here
377
    } else {
377
    } else {
378
        $sth2->execute();
378
        $sth2->execute();
379
    }
379
    }
380
    my $colauthvals = { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => $origcolumn } ) };
380
    my $colauthvals = { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => $origcolumn } ) };
381
    while ( my ($celvalue) = $sth2->fetchrow ) {
381
    while ( my ($celvalue) = $sth2->fetchrow ) {
382
        my %cell;
382
        my %cell;
383
        if (defined $celvalue and $celvalue ne '') {
383
        if (defined $celvalue and $celvalue ne '') {
(-)a/reports/issues_stats.pl (-2 / +2 lines)
Lines 90-97 $template->param(do_it => $do_it, Link Here
90
our $itemtypes = GetItemTypes();
90
our $itemtypes = GetItemTypes();
91
our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
91
our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
92
92
93
my $locations = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
93
my $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
94
my $ccodes = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
94
my $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
95
95
96
our $Bsort1 = GetAuthorisedValues("Bsort1");
96
our $Bsort1 = GetAuthorisedValues("Bsort1");
97
our $Bsort2 = GetAuthorisedValues("Bsort2");
97
our $Bsort2 = GetAuthorisedValues("Bsort2");
(-)a/reports/reserves_stats.pl (-4 / +4 lines)
Lines 84-91 $template->param(do_it => $do_it, Link Here
84
my $itemtypes = GetItemTypes();
84
my $itemtypes = GetItemTypes();
85
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
85
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
86
86
87
my $locations = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
87
my $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
88
my $ccodes = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
88
my $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
89
89
90
my $Bsort1 = GetAuthorisedValues("Bsort1");
90
my $Bsort1 = GetAuthorisedValues("Bsort1");
91
my $Bsort2 = GetAuthorisedValues("Bsort2");
91
my $Bsort2 = GetAuthorisedValues("Bsort2");
Lines 330-337 sub null_to_zzempty ($) { Link Here
330
}
330
}
331
sub display_value {
331
sub display_value {
332
    my ( $crit, $value ) = @_;
332
    my ( $crit, $value ) = @_;
333
    my $locations = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
333
    my $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
334
    my $ccodes = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
334
    my $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
335
    my $itemtypes = GetItemTypes();
335
    my $itemtypes = GetItemTypes();
336
    my $Bsort1 = GetAuthorisedValues("Bsort1");
336
    my $Bsort1 = GetAuthorisedValues("Bsort1");
337
    my $Bsort2 = GetAuthorisedValues("Bsort2");
337
    my $Bsort2 = GetAuthorisedValues("Bsort2");
(-)a/t/db_dependent/AuthorisedValues.t (-2 / +20 lines)
Lines 119-125 is( $categories[0], $av4->category, 'The first category should be correct (order Link Here
119
is( $categories[1], $av1->category, 'The second category should be correct (ordered by category name)' );
119
is( $categories[1], $av1->category, 'The second category should be correct (ordered by category name)' );
120
120
121
subtest 'search_by_*_field + find_by_koha_field + get_description' => sub {
121
subtest 'search_by_*_field + find_by_koha_field + get_description' => sub {
122
    plan tests => 4;
122
    plan tests => 5;
123
    my $loc_cat = Koha::AuthorisedValueCategories->find('LOC');
123
    my $loc_cat = Koha::AuthorisedValueCategories->find('LOC');
124
    $loc_cat->delete if $loc_cat;
124
    $loc_cat->delete if $loc_cat;
125
    my $mss = Koha::MarcSubfieldStructures->search( { tagfield => 952, tagsubfield => 'c', frameworkcode => '' } );
125
    my $mss = Koha::MarcSubfieldStructures->search( { tagfield => 952, tagsubfield => 'c', frameworkcode => '' } );
Lines 200-203 subtest 'search_by_*_field + find_by_koha_field + get_description' => sub { Link Here
200
            { kohafield => 'items.restricted', authorised_value => undef } );
200
            { kohafield => 'items.restricted', authorised_value => undef } );
201
        is_deeply( $descriptions, {}, ) ;    # This could be arguable, we could return undef instead
201
        is_deeply( $descriptions, {}, ) ;    # This could be arguable, we could return undef instead
202
    };
202
    };
203
    subtest 'get_descriptions_by_koha_field' => sub {
204
        plan tests => 1;
205
        my @descriptions = Koha::AuthorisedValues->get_descriptions_by_koha_field( { kohafield => 'items.restricted' } );
206
        is_deeply(
207
            \@descriptions,
208
            [
209
                {
210
                    authorised_value => '',
211
                    lib              => $av_empty_string->lib,
212
                    opac_description => $av_empty_string->lib_opac
213
                },
214
                {
215
                    authorised_value => $av_0->authorised_value,
216
                    lib              => $av_0->lib,
217
                    opac_description => $av_0->lib_opac
218
                }
219
            ],
220
        );
221
    };
203
};
222
};
204
- 

Return to bug 17642