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

(-)a/C4/Circulation.pm (-1 lines)
Lines 38-44 use C4::Log; # logaction Link Here
38
use C4::Koha qw(
38
use C4::Koha qw(
39
    GetAuthorisedValueByCode
39
    GetAuthorisedValueByCode
40
    GetAuthValCode
40
    GetAuthValCode
41
    GetKohaAuthorisedValueLib
42
);
41
);
43
use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units);
42
use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units);
44
use C4::RotatingCollections qw(GetCollectionItemBranches);
43
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 1380-1398 sub GetItemsInfo { Link Here
1380
1382
1381
        # get notforloan complete status if applicable
1383
        # get notforloan complete status if applicable
1382
        if ( my $code = C4::Koha::GetAuthValCode( 'items.notforloan', $data->{frameworkcode} ) ) {
1384
        if ( my $code = C4::Koha::GetAuthValCode( 'items.notforloan', $data->{frameworkcode} ) ) {
1383
            $data->{notforloanvalue}     = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{itemnotforloan} );
1385
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{itemnotforloan} });
1384
            $data->{notforloanvalueopac} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{itemnotforloan}, 1 );
1386
            $av = $av->count ? $av->next : undef;
1387
            $data->{notforloanvalue}     = $av ? $av->lib : '';
1388
            $data->{notforloanvalueopac} = $av ? $av->opac_description : '';
1385
        }
1389
        }
1386
1390
1387
        # get restricted status and description if applicable
1391
        # get restricted status and description if applicable
1388
        if ( my $code = C4::Koha::GetAuthValCode( 'items.restricted', $data->{frameworkcode} ) ) {
1392
        if ( my $code = C4::Koha::GetAuthValCode( 'items.restricted', $data->{frameworkcode} ) ) {
1389
            $data->{restrictedopac} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{restricted}, 1 );
1393
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{restricted} });
1390
            $data->{restricted}     = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{restricted} );
1394
            $av = $av->count ? $av->next : undef;
1395
            $data->{restricted}     = $av ? $av->lib : '';
1396
            $data->{restrictedopac} = $av ? $av->opac_description : '';
1391
        }
1397
        }
1392
1398
1393
        # my stack procedures
1399
        # my stack procedures
1394
        if ( my $code = C4::Koha::GetAuthValCode( 'items.stack', $data->{frameworkcode} ) ) {
1400
        if ( my $code = C4::Koha::GetAuthValCode( 'items.stack', $data->{frameworkcode} ) ) {
1395
            $data->{stack}          = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{stack} );
1401
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{stack} });
1402
            $data->{stack}          = $av->count ? $av->next->lib : '';
1396
        }
1403
        }
1397
1404
1398
        # Find the last 3 people who borrowed this item.
1405
        # Find the last 3 people who borrowed this item.
Lines 1477-1484 sub GetItemsLocationInfo { Link Here
1477
        $sth->execute($biblionumber);
1484
        $sth->execute($biblionumber);
1478
1485
1479
        while ( my $data = $sth->fetchrow_hashref ) {
1486
        while ( my $data = $sth->fetchrow_hashref ) {
1480
             $data->{location_intranet} = GetKohaAuthorisedValueLib('LOC', $data->{location});
1487
             my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $data->{location} });
1481
             $data->{location_opac}= GetKohaAuthorisedValueLib('LOC', $data->{location}, 1);
1488
             $av = $av->count ? $av->next : undef;
1489
             $data->{location_intranet} = $av ? $av->lib : '';
1490
             $data->{location_opac}     = $av ? $av->opac_description : '';
1482
	     push @results, $data;
1491
	     push @results, $data;
1483
	}
1492
	}
1484
	return @results;
1493
	return @results;
(-)a/C4/Koha.pm (-22 lines)
Lines 57-63 BEGIN { Link Here
57
		&GetKohaAuthorisedValues
57
		&GetKohaAuthorisedValues
58
		&GetKohaAuthorisedValuesFromField
58
		&GetKohaAuthorisedValuesFromField
59
    &GetKohaAuthorisedValuesMapping
59
    &GetKohaAuthorisedValuesMapping
60
    &GetKohaAuthorisedValueLib
61
    &GetAuthorisedValueByCode
60
    &GetAuthorisedValueByCode
62
		&GetAuthValCode
61
		&GetAuthValCode
63
		&GetNormalizedUPC
62
		&GetNormalizedUPC
Lines 1228-1254 sub xml_escape { Link Here
1228
    return $str;
1227
    return $str;
1229
}
1228
}
1230
1229
1231
=head2 GetKohaAuthorisedValueLib
1232
1233
Takes $category, $authorised_value as parameters.
1234
1235
If $opac parameter is set to a true value, displays OPAC descriptions rather than normal ones when they exist.
1236
1237
Returns authorised value description
1238
1239
=cut
1240
1241
sub GetKohaAuthorisedValueLib {
1242
  my ($category,$authorised_value,$opac) = @_;
1243
  my $value;
1244
  my $dbh = C4::Context->dbh;
1245
  my $sth = $dbh->prepare("select lib, lib_opac from authorised_values where category=? and authorised_value=?");
1246
  $sth->execute($category,$authorised_value);
1247
  my $data = $sth->fetchrow_hashref;
1248
  $value = ($opac && $$data{'lib_opac'}) ? $$data{'lib_opac'} : $$data{'lib'};
1249
  return $value;
1250
}
1251
1252
=head2 display_marc_indicators
1230
=head2 display_marc_indicators
1253
1231
1254
  my $display_form = C4::Koha::display_marc_indicators($field);
1232
  my $display_form = C4::Koha::display_marc_indicators($field);
(-)a/C4/Search.pm (-3 / +4 lines)
Lines 31-36 use C4::Branch; 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;
34
use Koha::Libraries;
35
use Koha::Libraries;
35
use YAML;
36
use YAML;
36
use URI::Escape;
37
use URI::Escape;
Lines 575-583 sub getRecords { Link Here
575
576
576
               # also, if it's a location code, use the name instead of the code
577
               # also, if it's a location code, use the name instead of the code
577
                                if ( $link_value =~ /location/ ) {
578
                                if ( $link_value =~ /location/ ) {
578
                                    $facet_label_value =
579
                                    # TODO Retrieve all authorised values at once, instead of 1 query per entry
579
                                      GetKohaAuthorisedValueLib( 'LOC',
580
                                    my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $one_facet });
580
                                        $one_facet, $opac );
581
                                    $facet_label_value = $av->count ? $av->next->opac_description : '';
581
                                }
582
                                }
582
583
583
                # but we're down with the whole label being in the link's title.
584
                # but we're down with the whole label being in the link's title.
(-)a/acqui/orderreceive.pl (-5 / +10 lines)
Lines 136-154 if ($AcqCreateItem eq 'receiving') { Link Here
136
            $item->{holdingbranchname} = GetBranchName($item->{holdingbranch});
136
            $item->{holdingbranchname} = GetBranchName($item->{holdingbranch});
137
        }
137
        }
138
        if(my $code = GetAuthValCode("items.notforloan", $fw)) {
138
        if(my $code = GetAuthValCode("items.notforloan", $fw)) {
139
            $item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan});
139
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{notforloan} });
140
            $item->{notforloan} = $av->count ? $av->next->lib : '';
140
        }
141
        }
141
        if(my $code = GetAuthValCode("items.restricted", $fw)) {
142
        if(my $code = GetAuthValCode("items.restricted", $fw)) {
142
            $item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted});
143
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{restricted} });
144
            $item->{restricted} = $av->count ? $av->next->lib : '';
143
        }
145
        }
144
        if(my $code = GetAuthValCode("items.location", $fw)) {
146
        if(my $code = GetAuthValCode("items.location", $fw)) {
145
            $item->{location} = GetKohaAuthorisedValueLib($code, $item->{location});
147
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{location} });
148
            $item->{location} = $av->count ? $av->next->lib : '';
146
        }
149
        }
147
        if(my $code = GetAuthValCode("items.ccode", $fw)) {
150
        if(my $code = GetAuthValCode("items.ccode", $fw)) {
148
            $item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode});
151
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{collection} });
152
            $item->{collection} = $av->count ? $av->next->lib : '';
149
        }
153
        }
150
        if(my $code = GetAuthValCode("items.materials", $fw)) {
154
        if(my $code = GetAuthValCode("items.materials", $fw)) {
151
            $item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials});
155
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{materials} });
156
            $item->{materials} = $av->count ? $av->next->lib : '';
152
        }
157
        }
153
        my $itemtype = getitemtypeinfo($item->{itype});
158
        my $itemtype = getitemtypeinfo($item->{itype});
154
        $item->{itemtype} = $itemtype->{description};
159
        $item->{itemtype} = $itemtype->{description};
(-)a/catalogue/getitem-ajax.pl (-5 / +12 lines)
Lines 28-33 use C4::Items; Link Here
28
use C4::Koha;
28
use C4::Koha;
29
use C4::Output;
29
use C4::Output;
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 33-38 use C4::Branch; # GetBranches Link Here
33
use C4::Koha;
33
use C4::Koha;
34
use C4::Members;
34
use C4::Members;
35
35
36
use Koha::AuthorisedValues;
37
36
###############################################
38
###############################################
37
#  Getting state
39
#  Getting state
38
40
Lines 130-136 if ($barcode) { Link Here
130
        $item{'itemtype'}              = $iteminformation->{'itemtype'};
132
        $item{'itemtype'}              = $iteminformation->{'itemtype'};
131
        $item{'ccode'}                 = $iteminformation->{'ccode'};
133
        $item{'ccode'}                 = $iteminformation->{'ccode'};
132
        $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
134
        $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
133
        $item{'location'}              = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'});
135
        my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $iteminformation->{location} });
136
        $item{'location'}              = $av->count ? $av->next->lib;
134
        $item{'frbrname'}              = $branches->{$frbranchcd}->{'branchname'};
137
        $item{'frbrname'}              = $branches->{$frbranchcd}->{'branchname'};
135
        $item{'tobrname'}              = $branches->{$tobranchcd}->{'branchname'};
138
        $item{'tobrname'}              = $branches->{$tobranchcd}->{'branchname'};
136
#         }
139
#         }
Lines 163-169 foreach ( $query->param ) { Link Here
163
    $item{'itemtype'}              = $iteminformation->{'itemtype'};
166
    $item{'itemtype'}              = $iteminformation->{'itemtype'};
164
    $item{'ccode'}                 = $iteminformation->{'ccode'};
167
    $item{'ccode'}                 = $iteminformation->{'ccode'};
165
    $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
168
    $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
166
    $item{'location'}              = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'});
169
    my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $iteminformation->{location} });
170
    $item{'location'}              = $av->count ? $av->next->lib;
167
    $item{'frbrname'}              = $branches->{$frbcd}->{'branchname'};
171
    $item{'frbrname'}              = $branches->{$frbcd}->{'branchname'};
168
    $item{'tobrname'}              = $branches->{$tobcd}->{'branchname'};
172
    $item{'tobrname'}              = $branches->{$tobcd}->{'branchname'};
169
    push( @trsfitemloop, \%item );
173
    push( @trsfitemloop, \%item );
(-)a/circ/circulation.pl (-1 / +3 lines)
Lines 43-48 use Koha::Holds; Link Here
43
use C4::Context;
43
use C4::Context;
44
use CGI::Session;
44
use CGI::Session;
45
use C4::Members::Attributes qw(GetBorrowerAttributes);
45
use C4::Members::Attributes qw(GetBorrowerAttributes);
46
use Koha::AuthorisedValues;
46
use Koha::Patron;
47
use Koha::Patron;
47
use Koha::Patron::Debarments qw(GetDebarments);
48
use Koha::Patron::Debarments qw(GetDebarments);
48
use Koha::DateUtils;
49
use Koha::DateUtils;
Lines 389-395 if (@$barcodes) { Link Here
389
            my $materials = $iteminfo->{'materials'};
390
            my $materials = $iteminfo->{'materials'};
390
            my $avcode = GetAuthValCode('items.materials');
391
            my $avcode = GetAuthValCode('items.materials');
391
            if ($avcode) {
392
            if ($avcode) {
392
                $materials = GetKohaAuthorisedValueLib($avcode, $materials);
393
                my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials });
394
                $materials = $av->count ? $av->next->lib : '';
393
            }
395
            }
394
            $template_params->{additional_materials} = $materials;
396
            $template_params->{additional_materials} = $materials;
395
            $template_params->{itemhomebranch} = $iteminfo->{'homebranch'};
397
            $template_params->{itemhomebranch} = $iteminfo->{'homebranch'};
(-)a/circ/returns.pl (-1 / +3 lines)
Lines 48-53 use C4::Members::Messaging; Link Here
48
use C4::Branch; # GetBranches GetBranchName
48
use C4::Branch; # GetBranches GetBranchName
49
use C4::Koha;   # FIXME : is it still useful ?
49
use C4::Koha;   # FIXME : is it still useful ?
50
use C4::RotatingCollections;
50
use C4::RotatingCollections;
51
use Koha::AuthorisedValues;
51
use Koha::DateUtils;
52
use Koha::DateUtils;
52
use Koha::Calendar;
53
use Koha::Calendar;
53
54
Lines 282-288 if ($barcode) { Link Here
282
    my $materials = $biblio->{'materials'};
283
    my $materials = $biblio->{'materials'};
283
    my $avcode = GetAuthValCode('items.materials');
284
    my $avcode = GetAuthValCode('items.materials');
284
    if ($avcode) {
285
    if ($avcode) {
285
        $materials = GetKohaAuthorisedValueLib($avcode, $materials);
286
        my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials });
287
        $materials = $av->count ? $av->next->lib : '';
286
    }
288
    }
287
289
288
    $template->param(
290
    $template->param(
(-)a/opac/opac-suggestions.pl (-1 / +4 lines)
Lines 28-33 use C4::Output; Link Here
28
use C4::Suggestions;
28
use C4::Suggestions;
29
use C4::Koha;
29
use C4::Koha;
30
use C4::Scrubber;
30
use C4::Scrubber;
31
32
use Koha::AuthorisedValues;
31
use Koha::Libraries;
33
use Koha::Libraries;
32
34
33
use Koha::DateUtils qw( dt_from_string );
35
use Koha::DateUtils qw( dt_from_string );
Lines 185-191 foreach my $suggestion(@$suggestions_loop) { Link Here
185
        $suggestion->{'showcheckbox'} = 0;
187
        $suggestion->{'showcheckbox'} = 0;
186
    }
188
    }
187
    if($suggestion->{'patronreason'}){
189
    if($suggestion->{'patronreason'}){
188
        $suggestion->{'patronreason'} = GetKohaAuthorisedValueLib("OPAC_SUG",$suggestion->{'patronreason'},1);
190
        my $av = Koha::AuthorisedValues->search({ category => 'OPAC_SUG', authorised_value => $suggestion->{patronreason} });
191
        $suggestion->{'patronreason'} = $av->count ? $av->next->opac_description : '';
189
    }
192
    }
190
}
193
}
191
194
(-)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