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

(-)a/C4/Circulation.pm (-1 lines)
Lines 37-43 use C4::Log; # logaction Link Here
37
use C4::Koha qw(
37
use C4::Koha qw(
38
    GetAuthorisedValueByCode
38
    GetAuthorisedValueByCode
39
    GetAuthValCode
39
    GetAuthValCode
40
    GetKohaAuthorisedValueLib
41
);
40
);
42
use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units);
41
use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units);
43
use C4::RotatingCollections qw(GetCollectionItemBranches);
42
use C4::RotatingCollections qw(GetCollectionItemBranches);
(-)a/C4/Items.pm (-7 / +16 lines)
Lines 34-39 use YAML qw/Load/; Link Here
34
use DateTime::Format::MySQL;
34
use DateTime::Format::MySQL;
35
use Data::Dumper; # used as part of logging item record changes, not just for
35
use Data::Dumper; # used as part of logging item record changes, not just for
36
                  # debugging; so please don't remove this
36
                  # debugging; so please don't remove this
37
38
use Koha::AuthorisedValues;
37
use Koha::DateUtils qw/dt_from_string/;
39
use Koha::DateUtils qw/dt_from_string/;
38
use Koha::Database;
40
use Koha::Database;
39
41
Lines 1381-1399 sub GetItemsInfo { Link Here
1381
1383
1382
        # get notforloan complete status if applicable
1384
        # get notforloan complete status if applicable
1383
        if ( my $code = C4::Koha::GetAuthValCode( 'items.notforloan', $data->{frameworkcode} ) ) {
1385
        if ( my $code = C4::Koha::GetAuthValCode( 'items.notforloan', $data->{frameworkcode} ) ) {
1384
            $data->{notforloanvalue}     = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{itemnotforloan} );
1386
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{itemnotforloan} });
1385
            $data->{notforloanvalueopac} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{itemnotforloan}, 1 );
1387
            $av = $av->count ? $av->next : undef;
1388
            $data->{notforloanvalue}     = $av ? $av->lib : '';
1389
            $data->{notforloanvalueopac} = $av ? $av->opac_description : '';
1386
        }
1390
        }
1387
1391
1388
        # get restricted status and description if applicable
1392
        # get restricted status and description if applicable
1389
        if ( my $code = C4::Koha::GetAuthValCode( 'items.restricted', $data->{frameworkcode} ) ) {
1393
        if ( my $code = C4::Koha::GetAuthValCode( 'items.restricted', $data->{frameworkcode} ) ) {
1390
            $data->{restrictedopac} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{restricted}, 1 );
1394
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{restricted} });
1391
            $data->{restricted}     = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{restricted} );
1395
            $av = $av->count ? $av->next : undef;
1396
            $data->{restricted}     = $av ? $av->lib : '';
1397
            $data->{restrictedopac} = $av ? $av->opac_description : '';
1392
        }
1398
        }
1393
1399
1394
        # my stack procedures
1400
        # my stack procedures
1395
        if ( my $code = C4::Koha::GetAuthValCode( 'items.stack', $data->{frameworkcode} ) ) {
1401
        if ( my $code = C4::Koha::GetAuthValCode( 'items.stack', $data->{frameworkcode} ) ) {
1396
            $data->{stack}          = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{stack} );
1402
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{stack} });
1403
            $data->{stack}          = $av->count ? $av->next->lib : '';
1397
        }
1404
        }
1398
1405
1399
        # Find the last 3 people who borrowed this item.
1406
        # Find the last 3 people who borrowed this item.
Lines 1478-1485 sub GetItemsLocationInfo { Link Here
1478
        $sth->execute($biblionumber);
1485
        $sth->execute($biblionumber);
1479
1486
1480
        while ( my $data = $sth->fetchrow_hashref ) {
1487
        while ( my $data = $sth->fetchrow_hashref ) {
1481
             $data->{location_intranet} = GetKohaAuthorisedValueLib('LOC', $data->{location});
1488
             my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $data->{location} });
1482
             $data->{location_opac}= GetKohaAuthorisedValueLib('LOC', $data->{location}, 1);
1489
             $av = $av->count ? $av->next : undef;
1490
             $data->{location_intranet} = $av ? $av->lib : '';
1491
             $data->{location_opac}     = $av ? $av->opac_description : '';
1483
	     push @results, $data;
1492
	     push @results, $data;
1484
	}
1493
	}
1485
	return @results;
1494
	return @results;
(-)a/C4/Koha.pm (-22 lines)
Lines 55-61 BEGIN { Link Here
55
		&GetKohaAuthorisedValues
55
		&GetKohaAuthorisedValues
56
		&GetKohaAuthorisedValuesFromField
56
		&GetKohaAuthorisedValuesFromField
57
    &GetKohaAuthorisedValuesMapping
57
    &GetKohaAuthorisedValuesMapping
58
    &GetKohaAuthorisedValueLib
59
    &GetAuthorisedValueByCode
58
    &GetAuthorisedValueByCode
60
		&GetAuthValCode
59
		&GetAuthValCode
61
		&GetNormalizedUPC
60
		&GetNormalizedUPC
Lines 1153-1179 sub xml_escape { Link Here
1153
    return $str;
1152
    return $str;
1154
}
1153
}
1155
1154
1156
=head2 GetKohaAuthorisedValueLib
1157
1158
Takes $category, $authorised_value as parameters.
1159
1160
If $opac parameter is set to a true value, displays OPAC descriptions rather than normal ones when they exist.
1161
1162
Returns authorised value description
1163
1164
=cut
1165
1166
sub GetKohaAuthorisedValueLib {
1167
  my ($category,$authorised_value,$opac) = @_;
1168
  my $value;
1169
  my $dbh = C4::Context->dbh;
1170
  my $sth = $dbh->prepare("select lib, lib_opac from authorised_values where category=? and authorised_value=?");
1171
  $sth->execute($category,$authorised_value);
1172
  my $data = $sth->fetchrow_hashref;
1173
  $value = ($opac && $$data{'lib_opac'}) ? $$data{'lib_opac'} : $$data{'lib'};
1174
  return $value;
1175
}
1176
1177
=head2 display_marc_indicators
1155
=head2 display_marc_indicators
1178
1156
1179
  my $display_form = C4::Koha::display_marc_indicators($field);
1157
  my $display_form = C4::Koha::display_marc_indicators($field);
(-)a/C4/Search.pm (-3 / +5 lines)
Lines 31-36 use C4::XSLT; Link Here
31
use C4::Reserves;    # GetReserveStatus
31
use C4::Reserves;    # GetReserveStatus
32
use C4::Debug;
32
use C4::Debug;
33
use C4::Charset;
33
use C4::Charset;
34
use Koha::AuthorisedValues;
35
use Koha::Libraries;
34
use YAML;
36
use YAML;
35
use URI::Escape;
37
use URI::Escape;
36
use Business::ISBN;
38
use Business::ISBN;
Lines 577-585 sub getRecords { Link Here
577
579
578
               # also, if it's a location code, use the name instead of the code
580
               # also, if it's a location code, use the name instead of the code
579
                                if ( $link_value =~ /location/ ) {
581
                                if ( $link_value =~ /location/ ) {
580
                                    $facet_label_value =
582
                                    # TODO Retrieve all authorised values at once, instead of 1 query per entry
581
                                      GetKohaAuthorisedValueLib( 'LOC',
583
                                    my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $one_facet });
582
                                        $one_facet, $opac );
584
                                    $facet_label_value = $av->count ? $av->next->opac_description : '';
583
                                }
585
                                }
584
586
585
                # but we're down with the whole label being in the link's title.
587
                # but we're down with the whole label being in the link's title.
(-)a/acqui/orderreceive.pl (-5 / +10 lines)
Lines 129-147 if ($AcqCreateItem eq 'receiving') { Link Here
129
    foreach (@itemnumbers) {
129
    foreach (@itemnumbers) {
130
        my $item = GetItem($_);
130
        my $item = GetItem($_);
131
        if(my $code = GetAuthValCode("items.notforloan", $fw)) {
131
        if(my $code = GetAuthValCode("items.notforloan", $fw)) {
132
            $item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan});
132
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{notforloan} });
133
            $item->{notforloan} = $av->count ? $av->next->lib : '';
133
        }
134
        }
134
        if(my $code = GetAuthValCode("items.restricted", $fw)) {
135
        if(my $code = GetAuthValCode("items.restricted", $fw)) {
135
            $item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted});
136
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{restricted} });
137
            $item->{restricted} = $av->count ? $av->next->lib : '';
136
        }
138
        }
137
        if(my $code = GetAuthValCode("items.location", $fw)) {
139
        if(my $code = GetAuthValCode("items.location", $fw)) {
138
            $item->{location} = GetKohaAuthorisedValueLib($code, $item->{location});
140
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{location} });
141
            $item->{location} = $av->count ? $av->next->lib : '';
139
        }
142
        }
140
        if(my $code = GetAuthValCode("items.ccode", $fw)) {
143
        if(my $code = GetAuthValCode("items.ccode", $fw)) {
141
            $item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode});
144
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{collection} });
145
            $item->{collection} = $av->count ? $av->next->lib : '';
142
        }
146
        }
143
        if(my $code = GetAuthValCode("items.materials", $fw)) {
147
        if(my $code = GetAuthValCode("items.materials", $fw)) {
144
            $item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials});
148
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{materials} });
149
            $item->{materials} = $av->count ? $av->next->lib : '';
145
        }
150
        }
146
        my $itemtype = getitemtypeinfo($item->{itype});
151
        my $itemtype = getitemtypeinfo($item->{itype});
147
        $item->{itemtype} = $itemtype->{description};
152
        $item->{itemtype} = $itemtype->{description};
(-)a/catalogue/getitem-ajax.pl (-5 / +12 lines)
Lines 28-33 use C4::Koha; Link Here
28
use C4::Output;
28
use C4::Output;
29
use Koha::Libraries;
29
use Koha::Libraries;
30
30
31
use Koha::AuthorisedValues;
32
31
my $cgi = new CGI;
33
my $cgi = new CGI;
32
34
33
my ( $status, $cookie, $sessionID ) = C4::Auth::check_api_auth( $cgi, { acquisition => 'order_receive' } );
35
my ( $status, $cookie, $sessionID ) = C4::Auth::check_api_auth( $cgi, { acquisition => 'order_receive' } );
Lines 54-76 if($itemnumber) { Link Here
54
    }
56
    }
55
57
56
    if(my $code = GetAuthValCode("items.notforloan", $fw)) {
58
    if(my $code = GetAuthValCode("items.notforloan", $fw)) {
57
        $item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan});
59
        my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{notforloan} });
60
        $item->{notforloan} = $av->count ? $av->next->lib : '';
58
    }
61
    }
59
62
60
    if(my $code = GetAuthValCode("items.restricted", $fw)) {
63
    if(my $code = GetAuthValCode("items.restricted", $fw)) {
61
        $item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted});
64
        my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{restricted} });
65
        $item->{restricted} = $av->count ? $av->next->lib : '';
62
    }
66
    }
63
67
64
    if(my $code = GetAuthValCode("items.location", $fw)) {
68
    if(my $code = GetAuthValCode("items.location", $fw)) {
65
        $item->{location} = GetKohaAuthorisedValueLib($code, $item->{location});
69
        my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{location} });
70
        $item->{location} = $av->count ? $av->next->lib : '';
66
    }
71
    }
67
72
68
    if(my $code = GetAuthValCode("items.ccode", $fw)) {
73
    if(my $code = GetAuthValCode("items.ccode", $fw)) {
69
        $item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode});
74
        my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{collection} });
75
        $item->{collection} = $av->count ? $av->next->lib : '';
70
    }
76
    }
71
77
72
    if(my $code = GetAuthValCode("items.materials", $fw)) {
78
    if(my $code = GetAuthValCode("items.materials", $fw)) {
73
        $item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials});
79
        my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{materials} });
80
        $item->{materials} = $av->count ? $av->next->lib : '';
74
    }
81
    }
75
82
76
    my $itemtype = getitemtypeinfo($item->{itype});
83
    my $itemtype = getitemtypeinfo($item->{itype});
(-)a/circ/branchtransfers.pl (-2 / +6 lines)
Lines 32-37 use C4::Auth qw/:DEFAULT get_session/; Link Here
32
use C4::Koha;
32
use C4::Koha;
33
use C4::Members;
33
use C4::Members;
34
34
35
use Koha::AuthorisedValues;
36
35
###############################################
37
###############################################
36
#  Getting state
38
#  Getting state
37
39
Lines 127-133 if ($barcode) { Link Here
127
        $item{'itemtype'}              = $iteminformation->{'itemtype'};
129
        $item{'itemtype'}              = $iteminformation->{'itemtype'};
128
        $item{'ccode'}                 = $iteminformation->{'ccode'};
130
        $item{'ccode'}                 = $iteminformation->{'ccode'};
129
        $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
131
        $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
130
        $item{'location'}              = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'});
132
        my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $iteminformation->{location} });
133
        $item{'location'}              = $av->count ? $av->next->lib : '';
131
#         }
134
#         }
132
        $item{counter}  = 0;
135
        $item{counter}  = 0;
133
        $item{barcode}  = $barcode;
136
        $item{barcode}  = $barcode;
Lines 158-164 foreach ( $query->param ) { Link Here
158
    $item{'itemtype'}              = $iteminformation->{'itemtype'};
161
    $item{'itemtype'}              = $iteminformation->{'itemtype'};
159
    $item{'ccode'}                 = $iteminformation->{'ccode'};
162
    $item{'ccode'}                 = $iteminformation->{'ccode'};
160
    $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
163
    $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
161
    $item{'location'}              = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'});
164
    my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $iteminformation->{location} });
165
    $item{'location'}              = $av->count ? $av->next->lib : '';
162
    push( @trsfitemloop, \%item );
166
    push( @trsfitemloop, \%item );
163
}
167
}
164
168
(-)a/circ/circulation.pl (-1 / +3 lines)
Lines 42-47 use Koha::Holds; Link Here
42
use C4::Context;
42
use C4::Context;
43
use CGI::Session;
43
use CGI::Session;
44
use C4::Members::Attributes qw(GetBorrowerAttributes);
44
use C4::Members::Attributes qw(GetBorrowerAttributes);
45
use Koha::AuthorisedValues;
45
use Koha::Patron;
46
use Koha::Patron;
46
use Koha::Patron::Debarments qw(GetDebarments);
47
use Koha::Patron::Debarments qw(GetDebarments);
47
use Koha::DateUtils;
48
use Koha::DateUtils;
Lines 391-397 if (@$barcodes) { Link Here
391
            my $materials = $iteminfo->{'materials'};
392
            my $materials = $iteminfo->{'materials'};
392
            my $avcode = GetAuthValCode('items.materials');
393
            my $avcode = GetAuthValCode('items.materials');
393
            if ($avcode) {
394
            if ($avcode) {
394
                $materials = GetKohaAuthorisedValueLib($avcode, $materials);
395
                my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials });
396
                $materials = $av->count ? $av->next->lib : '';
395
            }
397
            }
396
            $template_params->{additional_materials} = $materials;
398
            $template_params->{additional_materials} = $materials;
397
            $template_params->{itemhomebranch} = $iteminfo->{'homebranch'};
399
            $template_params->{itemhomebranch} = $iteminfo->{'homebranch'};
(-)a/circ/returns.pl (-1 / +3 lines)
Lines 47-52 use C4::Members; Link Here
47
use C4::Members::Messaging;
47
use C4::Members::Messaging;
48
use C4::Koha;   # FIXME : is it still useful ?
48
use C4::Koha;   # FIXME : is it still useful ?
49
use C4::RotatingCollections;
49
use C4::RotatingCollections;
50
use Koha::AuthorisedValues;
50
use Koha::DateUtils;
51
use Koha::DateUtils;
51
use Koha::Calendar;
52
use Koha::Calendar;
52
53
Lines 280-286 if ($barcode) { Link Here
280
    my $materials = $biblio->{'materials'};
281
    my $materials = $biblio->{'materials'};
281
    my $avcode = GetAuthValCode('items.materials');
282
    my $avcode = GetAuthValCode('items.materials');
282
    if ($avcode) {
283
    if ($avcode) {
283
        $materials = GetKohaAuthorisedValueLib($avcode, $materials);
284
        my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials });
285
        $materials = $av->count ? $av->next->lib : '';
284
    }
286
    }
285
287
286
    $template->param(
288
    $template->param(
(-)a/opac/opac-suggestions.pl (-1 / +4 lines)
Lines 27-32 use C4::Output; Link Here
27
use C4::Suggestions;
27
use C4::Suggestions;
28
use C4::Koha;
28
use C4::Koha;
29
use C4::Scrubber;
29
use C4::Scrubber;
30
31
use Koha::AuthorisedValues;
30
use Koha::Libraries;
32
use Koha::Libraries;
31
33
32
use Koha::DateUtils qw( dt_from_string );
34
use Koha::DateUtils qw( dt_from_string );
Lines 184-190 foreach my $suggestion(@$suggestions_loop) { Link Here
184
        $suggestion->{'showcheckbox'} = 0;
186
        $suggestion->{'showcheckbox'} = 0;
185
    }
187
    }
186
    if($suggestion->{'patronreason'}){
188
    if($suggestion->{'patronreason'}){
187
        $suggestion->{'patronreason'} = GetKohaAuthorisedValueLib("OPAC_SUG",$suggestion->{'patronreason'},1);
189
        my $av = Koha::AuthorisedValues->search({ category => 'OPAC_SUG', authorised_value => $suggestion->{patronreason} });
190
        $suggestion->{'patronreason'} = $av->count ? $av->next->opac_description : '';
188
    }
191
    }
189
}
192
}
190
193
(-)a/serials/subscription-detail.pl (-3 / +4 lines)
Lines 25-32 use C4::Serials; Link Here
25
use C4::Output;
25
use C4::Output;
26
use C4::Context;
26
use C4::Context;
27
use C4::Search qw/enabled_staff_search_views/;
27
use C4::Search qw/enabled_staff_search_views/;
28
use Koha::DateUtils;
29
28
29
use Koha::AuthorisedValues;
30
use Koha::DateUtils;
30
use Koha::Acquisition::Bookseller;
31
use Koha::Acquisition::Bookseller;
31
32
32
use Date::Calc qw/Today Day_of_Year Week_of_Year Add_Delta_Days/;
33
use Date::Calc qw/Today Day_of_Year Week_of_Year Add_Delta_Days/;
Lines 103-109 for my $date ( qw(startdate enddate firstacquidate histstartdate histenddate) ) Link Here
103
    $subs->{$date} = output_pref( { str => $subs->{$date}, dateonly => 1 } )
104
    $subs->{$date} = output_pref( { str => $subs->{$date}, dateonly => 1 } )
104
        if $subs->{$date};
105
        if $subs->{$date};
105
}
106
}
106
$subs->{location} = GetKohaAuthorisedValueLib("LOC",$subs->{location});
107
my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $subs->{location} });
108
$subs->{location} = $av->count ? $av->next->lib : '';
107
$subs->{abouttoexpire}  = abouttoexpire($subs->{subscriptionid});
109
$subs->{abouttoexpire}  = abouttoexpire($subs->{subscriptionid});
108
$template->param(%{ $subs });
110
$template->param(%{ $subs });
109
$template->param(biblionumber_for_new_subscription => $subs->{bibnum});
111
$template->param(biblionumber_for_new_subscription => $subs->{bibnum});
110
- 

Return to bug 17248