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

(-)a/C4/Items.pm (-9 / +9 lines)
Lines 1374-1393 sub GetItemsInfo { Link Here
1374
1374
1375
        $serial ||= $data->{'serial'};
1375
        $serial ||= $data->{'serial'};
1376
1376
1377
        my $av;
1377
        my $descriptions;
1378
        # get notforloan complete status if applicable
1378
        # get notforloan complete status if applicable
1379
        $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.notforloan', authorised_value => $data->{itemnotforloan} });
1379
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.notforloan', authorised_value => $data->{itemnotforloan} });
1380
        $data->{notforloanvalue}     = $av ? $av->lib : '';
1380
        $data->{notforloanvalue}     = $descriptions->{lib} // '';
1381
        $data->{notforloanvalueopac} = $av ? $av->opac_description : '';
1381
        $data->{notforloanvalueopac} = $descriptions->{opac_description} // '';
1382
1382
1383
        # get restricted status and description if applicable
1383
        # get restricted status and description if applicable
1384
        $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.restricted', authorised_value => $data->{restricted} });
1384
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.restricted', authorised_value => $data->{restricted} });
1385
        $data->{restricted}     = $av ? $av->lib : '';
1385
        $data->{restricted}     = $descriptions->{lib} // '';
1386
        $data->{restrictedopac} = $av ? $av->opac_description : '';
1386
        $data->{restrictedopac} = $descriptions->{opac_description} // '';
1387
1387
1388
        # my stack procedures
1388
        # my stack procedures
1389
        $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.stack', authorised_value => $data->{stack} });
1389
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.stack', authorised_value => $data->{stack} });
1390
        $data->{stack}          = $av ? $av->lib : '';
1390
        $data->{stack}          = $descriptions->{lib} // '';
1391
1391
1392
        # Find the last 3 people who borrowed this item.
1392
        # Find the last 3 people who borrowed this item.
1393
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
1393
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
(-)a/Koha/AuthorisedValues.pm (-1 / +1 lines)
Lines 129-135 sub get_description_by_koha_field { Link Here
129
    return {} unless defined $authorised_value;
129
    return {} unless defined $authorised_value;
130
130
131
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance;
131
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance;
132
    my $cache_key    = "Av_descriptions:$frameworkcode:$kohafield:$authorised_value";
132
    my $cache_key    = "AV_descriptions:$frameworkcode:$kohafield:$authorised_value";
133
    my $cached       = $memory_cache->get_from_cache($cache_key);
133
    my $cached       = $memory_cache->get_from_cache($cache_key);
134
    return $cached if $cached;
134
    return $cached if $cached;
135
135
(-)a/acqui/orderreceive.pl (-11 / +11 lines)
Lines 128-148 if ($AcqCreateItem eq 'receiving') { Link Here
128
    my @items;
128
    my @items;
129
    foreach (@itemnumbers) {
129
    foreach (@itemnumbers) {
130
        my $item = GetItem($_);
130
        my $item = GetItem($_);
131
        my $av;
131
        my $descriptions;
132
        $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} });
132
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} });
133
        $item->{notforloan} = $av ? $av->lib : '';
133
        $item->{notforloan} = $descriptions->{lib} // '';
134
134
135
        $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} });
135
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} });
136
        $item->{restricted} = $av ? $av->lib : '';
136
        $item->{restricted} = $descriptions->{lib} // '';
137
137
138
        $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} });
138
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} });
139
        $item->{location} = $av ? $av->lib : '';
139
        $item->{location} = $descriptions->{lib} // '';
140
140
141
        $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} });
141
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} });
142
        $item->{collection} = $av ? $av->lib : '';
142
        $item->{collection} = $descriptions->{lib} // '';
143
143
144
        $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
144
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
145
        $item->{materials} = $av ? $av->lib : '';
145
        $item->{materials} = $descriptions->{lib} // '';
146
146
147
        my $itemtype = getitemtypeinfo($item->{itype});
147
        my $itemtype = getitemtypeinfo($item->{itype});
148
        $item->{itemtype} = $itemtype->{description};
148
        $item->{itemtype} = $itemtype->{description};
(-)a/catalogue/getitem-ajax.pl (-11 / +11 lines)
Lines 55-75 if($itemnumber) { Link Here
55
        $item->{holdingbranchname} = Koha::Libraries->find($item->{holdingbranch})->branchname;
55
        $item->{holdingbranchname} = Koha::Libraries->find($item->{holdingbranch})->branchname;
56
    }
56
    }
57
57
58
    my $av;
58
    my $descriptions;
59
    $av = Koha::AuthorisedValues->find_by_koha_field({ frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} });
59
    $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} });
60
    $item->{notforloan} = $av ? $av->lib : '';
60
    $item->{notforloan} = $descriptions->{lib} // '';
61
61
62
    $av = Koha::AuthorisedValues->find_by_koha_field({ frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} });
62
    $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} });
63
    $item->{restricted} = $av ? $av->lib : '';
63
    $item->{restricted} = $descriptions->{lib} // '';
64
64
65
    $av = Koha::AuthorisedValues->find_by_koha_field({ frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} });
65
    $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} });
66
    $item->{location} = $av ? $av->lib : '';
66
    $item->{location} = $descriptions->{lib} // '';
67
67
68
    $av = Koha::AuthorisedValues->find_by_koha_field({ frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} });
68
    $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} });
69
    $item->{collection} = $av ? $av->lib : '';
69
    $item->{collection} = $descriptions->{lib} // '';
70
70
71
    $av = Koha::AuthorisedValues->find_by_koha_field({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
71
    $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
72
    $item->{materials} = $av ? $av->lib : '';
72
    $item->{materials} = $descriptions->{lib} // '';
73
73
74
    my $itemtype = getitemtypeinfo($item->{itype});
74
    my $itemtype = getitemtypeinfo($item->{itype});
75
    $item->{itemtype} = $itemtype->{description};
75
    $item->{itemtype} = $itemtype->{description};
(-)a/circ/circulation.pl (-2 / +2 lines)
Lines 393-400 if (@$barcodes) { Link Here
393
        unless($issueconfirmed){
393
        unless($issueconfirmed){
394
            #  Get the item title for more information
394
            #  Get the item title for more information
395
            my $materials = $iteminfo->{'materials'};
395
            my $materials = $iteminfo->{'materials'};
396
            my $av = Koha::AuthorisedValues->find_by_koha_field({ frameworkcode => $getmessageiteminfo->{frameworkcode}, kohafield => 'items.materials', authorised_value => $materials });
396
            my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $getmessageiteminfo->{frameworkcode}, kohafield => 'items.materials', authorised_value => $materials });
397
            $materials = $av ? $av->lib : '';
397
            $materials = $descriptions->{lib} // '';
398
            $template_params->{additional_materials} = $materials;
398
            $template_params->{additional_materials} = $materials;
399
            $template_params->{itemhomebranch} = $iteminfo->{'homebranch'};
399
            $template_params->{itemhomebranch} = $iteminfo->{'homebranch'};
400
400
(-)a/circ/returns.pl (-2 / +2 lines)
Lines 279-286 if ($barcode) { Link Here
279
    $returnbranch = $biblio->{$hbr};
279
    $returnbranch = $biblio->{$hbr};
280
280
281
    my $materials = $biblio->{'materials'};
281
    my $materials = $biblio->{'materials'};
282
    my $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
282
    my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
283
    $materials = $av ? $av->lib : '';
283
    $materials = $descriptions->{lib} // '';
284
284
285
    $template->param(
285
    $template->param(
286
        title            => $biblio->{'title'},
286
        title            => $biblio->{'title'},
(-)a/t/db_dependent/AuthorisedValues.t (-2 / +1 lines)
Lines 118-124 is( @categories, 3, 'There should have 2 categories inserted' ); Link Here
118
is( $categories[0], $av4->category, 'The first category should be correct (ordered by category name)' );
118
is( $categories[0], $av4->category, 'The first category should be correct (ordered by category name)' );
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 + search_for_descriptions' => sub {
121
subtest 'search_by_*_field + find_by_koha_field + get_description' => sub {
122
    plan tests => 4;
122
    plan tests => 4;
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
- 

Return to bug 17642