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

(-)a/C4/ILSDI/Services.pm (-5 / +15 lines)
Lines 262-272 sub GetRecords { Link Here
262
            $item{'homebranchname'}    = $home_library    ? $home_library->branchname    : '';
262
            $item{'homebranchname'}    = $home_library    ? $home_library->branchname    : '';
263
            $item{'holdingbranchname'} = $holding_library ? $holding_library->branchname : '';
263
            $item{'holdingbranchname'} = $holding_library ? $holding_library->branchname : '';
264
264
265
            if ( $item->location ) {
265
            my $item_strings = $item->strings_map;
266
                my $authorised_value = Koha::AuthorisedValues->get_description_by_koha_field(
266
            foreach my $field ( keys %{$item_strings} ) {
267
                    { frameworkcode => '', kohafield => 'items.location', authorised_value => $item->location } );
267
                if ( $item->$field ) {
268
                if ($authorised_value) {
268
                    my $authorised_value =
269
                    $item{location_description} = $authorised_value->{opac_description};
269
                      Koha::AuthorisedValues->get_description_by_koha_field(
270
                        {
271
                            frameworkcode    => '',
272
                            kohafield        => 'items.' . $field,
273
                            authorised_value => $item->$field
274
                        }
275
                      );
276
                    if ($authorised_value) {
277
                        $item{ $field . '_description' } =
278
                          $authorised_value->{opac_description};
279
                    }
270
                }
280
                }
271
            }
281
            }
272
282
(-)a/t/db_dependent/AuthorisedValues.t (-3 / +10 lines)
Lines 228-235 subtest 'search_by_*_field + find_by_koha_field + get_description + authorised_v Link Here
228
228
229
    };
229
    };
230
    subtest 'find_by_koha_field' => sub {
230
    subtest 'find_by_koha_field' => sub {
231
        plan tests => 3;
231
        plan tests => 4;
232
233
        # Test authorised_value = 0
232
        # Test authorised_value = 0
234
        my $av;
233
        my $av;
235
        $av = Koha::AuthorisedValues->find_by_koha_field( { kohafield => 'items.restricted', authorised_value => 0 } );
234
        $av = Koha::AuthorisedValues->find_by_koha_field( { kohafield => 'items.restricted', authorised_value => 0 } );
Lines 243-248 subtest 'search_by_*_field + find_by_koha_field + get_description + authorised_v Link Here
243
        $av = Koha::AuthorisedValues->find_by_koha_field(
242
        $av = Koha::AuthorisedValues->find_by_koha_field(
244
            { kohafield => 'items.restricted', authorised_value => undef } );
243
            { kohafield => 'items.restricted', authorised_value => undef } );
245
        is( $av, undef, );
244
        is( $av, undef, );
245
        # Test get authorised_value->opac_description if kohafield is in array
246
        my @authorised_kohafields = ( 'location', 'ccode', 'permanent_location', 'notforloan', 'itemlost', 'withdrawn', 'damaged', 'restricted' );
247
        foreach my $kohafield (@authorised_kohafields) {
248
            $av = Koha::AuthorisedValues->find_by_koha_field( { kohafield => 'items.' . $kohafield, authorised_value => 'location_1' } );
249
            if ($av) {
250
                is(
251
                    $av->opac_description, 'location_1', "items.$kohafield description added correctly" );
252
            }
253
        }
246
    };
254
    };
247
    subtest 'get_description_by_koha_field' => sub {
255
    subtest 'get_description_by_koha_field' => sub {
248
        plan tests => 4;
256
        plan tests => 4;
249
- 

Return to bug 31550