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 1377-1395 sub GetItemsInfo { Link Here
1377
1379
1378
        # get notforloan complete status if applicable
1380
        # get notforloan complete status if applicable
1379
        if ( my $code = C4::Koha::GetAuthValCode( 'items.notforloan', $data->{frameworkcode} ) ) {
1381
        if ( my $code = C4::Koha::GetAuthValCode( 'items.notforloan', $data->{frameworkcode} ) ) {
1380
            $data->{notforloanvalue}     = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{itemnotforloan} );
1382
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{itemnotforloan} });
1381
            $data->{notforloanvalueopac} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{itemnotforloan}, 1 );
1383
            $av = $av->count ? $av->next : undef;
1384
            $data->{notforloanvalue}     = $av ? $av->lib : '';
1385
            $data->{notforloanvalueopac} = $av ? $av->opac_description : '';
1382
        }
1386
        }
1383
1387
1384
        # get restricted status and description if applicable
1388
        # get restricted status and description if applicable
1385
        if ( my $code = C4::Koha::GetAuthValCode( 'items.restricted', $data->{frameworkcode} ) ) {
1389
        if ( my $code = C4::Koha::GetAuthValCode( 'items.restricted', $data->{frameworkcode} ) ) {
1386
            $data->{restrictedopac} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{restricted}, 1 );
1390
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{restricted} });
1387
            $data->{restricted}     = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{restricted} );
1391
            $av = $av->count ? $av->next : undef;
1392
            $data->{restricted}     = $av ? $av->lib : '';
1393
            $data->{restrictedopac} = $av ? $av->opac_description : '';
1388
        }
1394
        }
1389
1395
1390
        # my stack procedures
1396
        # my stack procedures
1391
        if ( my $code = C4::Koha::GetAuthValCode( 'items.stack', $data->{frameworkcode} ) ) {
1397
        if ( my $code = C4::Koha::GetAuthValCode( 'items.stack', $data->{frameworkcode} ) ) {
1392
            $data->{stack}          = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{stack} );
1398
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{stack} });
1399
            $data->{stack}          = $av->count ? $av->next->lib : '';
1393
        }
1400
        }
1394
1401
1395
        # Find the last 3 people who borrowed this item.
1402
        # Find the last 3 people who borrowed this item.
Lines 1474-1481 sub GetItemsLocationInfo { Link Here
1474
        $sth->execute($biblionumber);
1481
        $sth->execute($biblionumber);
1475
1482
1476
        while ( my $data = $sth->fetchrow_hashref ) {
1483
        while ( my $data = $sth->fetchrow_hashref ) {
1477
             $data->{location_intranet} = GetKohaAuthorisedValueLib('LOC', $data->{location});
1484
             my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $data->{location} });
1478
             $data->{location_opac}= GetKohaAuthorisedValueLib('LOC', $data->{location}, 1);
1485
             $av = $av->count ? $av->next : undef;
1486
             $data->{location_intranet} = $av ? $av->lib : '';
1487
             $data->{location_opac}     = $av ? $av->opac_description : '';
1479
	     push @results, $data;
1488
	     push @results, $data;
1480
	}
1489
	}
1481
	return @results;
1490
	return @results;
(-)a/C4/Koha.pm (-22 lines)
Lines 56-62 BEGIN { Link Here
56
		&GetKohaAuthorisedValues
56
		&GetKohaAuthorisedValues
57
		&GetKohaAuthorisedValuesFromField
57
		&GetKohaAuthorisedValuesFromField
58
    &GetKohaAuthorisedValuesMapping
58
    &GetKohaAuthorisedValuesMapping
59
    &GetKohaAuthorisedValueLib
60
    &GetAuthorisedValueByCode
59
    &GetAuthorisedValueByCode
61
		&GetAuthValCode
60
		&GetAuthValCode
62
		&GetNormalizedUPC
61
		&GetNormalizedUPC
Lines 1227-1253 sub xml_escape { Link Here
1227
    return $str;
1226
    return $str;
1228
}
1227
}
1229
1228
1230
=head2 GetKohaAuthorisedValueLib
1231
1232
Takes $category, $authorised_value as parameters.
1233
1234
If $opac parameter is set to a true value, displays OPAC descriptions rather than normal ones when they exist.
1235
1236
Returns authorised value description
1237
1238
=cut
1239
1240
sub GetKohaAuthorisedValueLib {
1241
  my ($category,$authorised_value,$opac) = @_;
1242
  my $value;
1243
  my $dbh = C4::Context->dbh;
1244
  my $sth = $dbh->prepare("select lib, lib_opac from authorised_values where category=? and authorised_value=?");
1245
  $sth->execute($category,$authorised_value);
1246
  my $data = $sth->fetchrow_hashref;
1247
  $value = ($opac && $$data{'lib_opac'}) ? $$data{'lib_opac'} : $$data{'lib'};
1248
  return $value;
1249
}
1250
1251
=head2 display_marc_indicators
1229
=head2 display_marc_indicators
1252
1230
1253
  my $display_form = C4::Koha::display_marc_indicators($field);
1231
  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 388-394 if (@$barcodes) { Link Here
388
            my $materials = $iteminfo->{'materials'};
389
            my $materials = $iteminfo->{'materials'};
389
            my $avcode = GetAuthValCode('items.materials');
390
            my $avcode = GetAuthValCode('items.materials');
390
            if ($avcode) {
391
            if ($avcode) {
391
                $materials = GetKohaAuthorisedValueLib($avcode, $materials);
392
                my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials });
393
                $materials = $av->count ? $av->next->lib : '';
392
            }
394
            }
393
            $template_params->{additional_materials} = $materials;
395
            $template_params->{additional_materials} = $materials;
394
            $template_params->{itemhomebranch} = $iteminfo->{'homebranch'};
396
            $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 279-285 if ($barcode) { Link Here
279
    my $materials = $biblio->{'materials'};
280
    my $materials = $biblio->{'materials'};
280
    my $avcode = GetAuthValCode('items.materials');
281
    my $avcode = GetAuthValCode('items.materials');
281
    if ($avcode) {
282
    if ($avcode) {
282
        $materials = GetKohaAuthorisedValueLib($avcode, $materials);
283
        my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials });
284
        $materials = $av->count ? $av->next->lib : '';
283
    }
285
    }
284
286
285
    $template->param(
287
    $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