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

(-)a/C4/Circulation.pm (-1 lines)
Lines 37-43 use C4::Branch; # GetBranches Link Here
37
use C4::Log; # logaction
37
use C4::Log; # logaction
38
use C4::Koha qw(
38
use C4::Koha qw(
39
    GetAuthorisedValueByCode
39
    GetAuthorisedValueByCode
40
    GetAuthValCode
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 (-16 / +11 lines)
Lines 1380-1406 sub GetItemsInfo { Link Here
1380
1380
1381
        $serial ||= $data->{'serial'};
1381
        $serial ||= $data->{'serial'};
1382
1382
1383
        my $av;
1383
        # get notforloan complete status if applicable
1384
        # get notforloan complete status if applicable
1384
        if ( my $code = C4::Koha::GetAuthValCode( 'items.notforloan', $data->{frameworkcode} ) ) {
1385
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.notforloan', authorised_value => $data->{itemnotforloan} });
1385
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{itemnotforloan} });
1386
        $av = $av->count ? $av->next : undef;
1386
            $av = $av->count ? $av->next : undef;
1387
        $data->{notforloanvalue}     = $av ? $av->lib : '';
1387
            $data->{notforloanvalue}     = $av ? $av->lib : '';
1388
        $data->{notforloanvalueopac} = $av ? $av->opac_description : '';
1388
            $data->{notforloanvalueopac} = $av ? $av->opac_description : '';
1389
        }
1390
1389
1391
        # get restricted status and description if applicable
1390
        # get restricted status and description if applicable
1392
        if ( my $code = C4::Koha::GetAuthValCode( 'items.restricted', $data->{frameworkcode} ) ) {
1391
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.restricted', authorised_value => $data->{restricted} });
1393
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{restricted} });
1392
        $av = $av->count ? $av->next : undef;
1394
            $av = $av->count ? $av->next : undef;
1393
        $data->{restricted}     = $av ? $av->lib : '';
1395
            $data->{restricted}     = $av ? $av->lib : '';
1394
        $data->{restrictedopac} = $av ? $av->opac_description : '';
1396
            $data->{restrictedopac} = $av ? $av->opac_description : '';
1397
        }
1398
1395
1399
        # my stack procedures
1396
        # my stack procedures
1400
        if ( my $code = C4::Koha::GetAuthValCode( 'items.stack', $data->{frameworkcode} ) ) {
1397
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.stack', authorised_value => $data->{stack} });
1401
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{stack} });
1398
        $data->{stack}          = $av->count ? $av->next->lib : '';
1402
            $data->{stack}          = $av->count ? $av->next->lib : '';
1403
        }
1404
1399
1405
        # Find the last 3 people who borrowed this item.
1400
        # Find the last 3 people who borrowed this item.
1406
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
1401
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
(-)a/C4/Koha.pm (-32 / +12 lines)
Lines 58-64 BEGIN { Link Here
58
		&GetKohaAuthorisedValues
58
		&GetKohaAuthorisedValues
59
    &GetKohaAuthorisedValuesMapping
59
    &GetKohaAuthorisedValuesMapping
60
    &GetAuthorisedValueByCode
60
    &GetAuthorisedValueByCode
61
		&GetAuthValCode
62
		&GetNormalizedUPC
61
		&GetNormalizedUPC
63
		&GetNormalizedISBN
62
		&GetNormalizedISBN
64
		&GetNormalizedEAN
63
		&GetNormalizedEAN
Lines 955-976 SELECT lib, Link Here
955
    return \%notforloan_label_of;
954
    return \%notforloan_label_of;
956
}
955
}
957
956
958
=head2 GetAuthValCode
959
960
  $authvalcode = GetAuthValCode($kohafield,$frameworkcode);
961
962
=cut
963
964
sub GetAuthValCode {
965
	my ($kohafield,$fwcode) = @_;
966
	my $dbh = C4::Context->dbh;
967
	$fwcode='' unless $fwcode;
968
	my $sth = $dbh->prepare('select authorised_value from marc_subfield_structure where kohafield=? and frameworkcode=?');
969
	$sth->execute($kohafield,$fwcode);
970
	my ($authvalcode) = $sth->fetchrow_array;
971
	return $authvalcode;
972
}
973
974
=head2 GetAuthorisedValues
957
=head2 GetAuthorisedValues
975
958
976
  $authvalues = GetAuthorisedValues([$category]);
959
  $authvalues = GetAuthorisedValues([$category]);
Lines 1092-1112 Returns undef if no authorised value category is defined for the kohafield. Link Here
1092
=cut
1075
=cut
1093
1076
1094
sub GetKohaAuthorisedValues {
1077
sub GetKohaAuthorisedValues {
1095
  my ($kohafield,$fwcode,$opac) = @_;
1078
    my ( $kohafield, $fwcode, $opac ) = @_;
1096
  $fwcode='' unless $fwcode;
1079
    $fwcode = '' unless $fwcode;
1097
  my %values;
1080
    my %values;
1098
  my $dbh = C4::Context->dbh;
1081
    my $dbh = C4::Context->dbh;
1099
  my $avcode = GetAuthValCode($kohafield,$fwcode);
1082
1100
  if ($avcode) {  
1083
    my $avs = Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fwcode, kohafield => $kohafield } );
1101
	my $sth = $dbh->prepare("select authorised_value, lib, lib_opac from authorised_values where category=? ");
1084
    return {} unless $avs->count;
1102
   	$sth->execute($avcode);
1085
    my $values;
1103
	while ( my ($val, $lib, $lib_opac) = $sth->fetchrow_array ) { 
1086
    while ( my $av = $avs->next ) {
1104
		$values{$val} = ($opac && $lib_opac) ? $lib_opac : $lib;
1087
        $values->{ $av->authorised_value } = $opac ? $av->opac_description : $av->lib;
1105
   	}
1088
    }
1106
   	return \%values;
1089
    return $values;
1107
  } else {
1108
	return;
1109
  }
1110
}
1090
}
1111
1091
1112
=head2 GetKohaAuthorisedValuesMapping
1092
=head2 GetKohaAuthorisedValuesMapping
(-)a/C4/Search.pm (-1 / +2 lines)
Lines 1854-1860 sub searchResults { Link Here
1854
    my $shelflocations =GetKohaAuthorisedValues('items.location','');
1854
    my $shelflocations =GetKohaAuthorisedValues('items.location','');
1855
1855
1856
    # get notforloan authorised value list (see $shelflocations  FIXME)
1856
    # get notforloan authorised value list (see $shelflocations  FIXME)
1857
    my $notforloan_authorised_value = GetAuthValCode('items.notforloan','');
1857
    my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan' });
1858
    my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef;
1858
1859
1859
    #Get itemtype hash
1860
    #Get itemtype hash
1860
    my %itemtypes = %{ GetItemTypes() };
1861
    my %itemtypes = %{ GetItemTypes() };
(-)a/Koha/AuthorisedValues.pm (+22 lines)
Lines 80-85 sub search_by_marc_field { Link Here
80
    );
80
    );
81
}
81
}
82
82
83
sub search_by_koha_field {
84
    my ( $self, $params ) = @_;
85
    my $frameworkcode    = $params->{frameworkcode} || '';
86
    my $kohafield        = $params->{kohafield};
87
    my $category         = $params->{category};
88
    my $authorised_value = $params->{authorised_value};
89
90
    return unless $kohafield;
91
92
    return $self->SUPER::search(
93
        {   'marc_subfield_structures.frameworkcode' => $frameworkcode,
94
            'marc_subfield_structures.kohafield'     => $kohafield,
95
            ( defined $category ? ( category_name    => $category )         : () ),
96
            ( $authorised_value ? ( authorised_value => $authorised_value ) : () ),
97
        },
98
        {   join     => { category => 'marc_subfield_structures' },
99
            select   => ['authorised_value'],
100
            distinct => 1,
101
        }
102
    );
103
}
104
83
sub categories {
105
sub categories {
84
    my ( $self ) = @_;
106
    my ( $self ) = @_;
85
    my $rs = $self->_resultset->search(
107
    my $rs = $self->_resultset->search(
(-)a/acqui/orderreceive.pl (-20 / +16 lines)
Lines 135-160 if ($AcqCreateItem eq 'receiving') { Link Here
135
        if($item->{holdingbranch}) {
135
        if($item->{holdingbranch}) {
136
            $item->{holdingbranchname} = GetBranchName($item->{holdingbranch});
136
            $item->{holdingbranchname} = GetBranchName($item->{holdingbranch});
137
        }
137
        }
138
        if(my $code = GetAuthValCode("items.notforloan", $fw)) {
138
        my $av;
139
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{notforloan} });
139
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} });
140
            $item->{notforloan} = $av->count ? $av->next->lib : '';
140
        $item->{notforloan} = $av->count ? $av->next->lib : '';
141
        }
141
142
        if(my $code = GetAuthValCode("items.restricted", $fw)) {
142
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} });
143
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{restricted} });
143
        $item->{restricted} = $av->count ? $av->next->lib : '';
144
            $item->{restricted} = $av->count ? $av->next->lib : '';
144
145
        }
145
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} });
146
        if(my $code = GetAuthValCode("items.location", $fw)) {
146
        $item->{location} = $av->count ? $av->next->lib : '';
147
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{location} });
147
148
            $item->{location} = $av->count ? $av->next->lib : '';
148
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} });
149
        }
149
        $item->{collection} = $av->count ? $av->next->lib : '';
150
        if(my $code = GetAuthValCode("items.ccode", $fw)) {
150
151
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{collection} });
151
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
152
            $item->{collection} = $av->count ? $av->next->lib : '';
152
        $item->{materials} = $av->count ? $av->next->lib : '';
153
        }
153
154
        if(my $code = GetAuthValCode("items.materials", $fw)) {
155
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{materials} });
156
            $item->{materials} = $av->count ? $av->next->lib : '';
157
        }
158
        my $itemtype = getitemtypeinfo($item->{itype});
154
        my $itemtype = getitemtypeinfo($item->{itype});
159
        $item->{itemtype} = $itemtype->{description};
155
        $item->{itemtype} = $itemtype->{description};
160
        push @items, $item;
156
        push @items, $item;
(-)a/catalogue/detail.pl (-7 / +10 lines)
Lines 42-47 use Koha::DateUtils; Link Here
42
use C4::HTML5Media;
42
use C4::HTML5Media;
43
use C4::CourseReserves qw(GetItemCourseReservesInfo);
43
use C4::CourseReserves qw(GetItemCourseReservesInfo);
44
use C4::Acquisition qw(GetOrdersByBiblionumber);
44
use C4::Acquisition qw(GetOrdersByBiblionumber);
45
use Koha::AuthorisedValues;
45
use Koha::Virtualshelves;
46
use Koha::Virtualshelves;
46
47
47
my $query = CGI->new();
48
my $query = CGI->new();
Lines 197-213 my $copynumbers = GetKohaAuthorisedValues('items.copynumber', $fw); Link Here
197
my (@itemloop, @otheritemloop, %itemfields);
198
my (@itemloop, @otheritemloop, %itemfields);
198
my $norequests = 1;
199
my $norequests = 1;
199
200
200
if ( my $lost_av = GetAuthValCode('items.itemlost', $fw) ) {
201
my $mss = Koha::MarcSubfieldStructure->search({ frameworkcode => $fw, kohafield => 'items.itemlost' });
201
    $template->param( itemlostloop => GetAuthorisedValues( $lost_av ) );
202
if ( $mss->count ) {
203
    $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) );
202
}
204
}
203
if ( my $damaged_av = GetAuthValCode('items.damaged', $fw) ) {
205
$mss = Koha::MarcSubfieldStructure->search({ frameworkcode => $fw, kohafield => 'items.damaged' });
204
    $template->param( itemdamagedloop => GetAuthorisedValues( $damaged_av ) );
206
if ( $mss->count ) {
207
    $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) );
205
}
208
}
206
209
207
my $materials_authvalcode = GetAuthValCode('items.materials', $fw);
210
$mss = Koha::MarcSubfieldStructure->search({ frameworkcode => $fw, kohafield => 'items.materials' });
208
my %materials_map;
211
my %materials_map;
209
if ($materials_authvalcode) {
212
if ($mss->count) {
210
    my $materials_authvals = GetAuthorisedValues($materials_authvalcode);
213
    my $materials_authvals = GetAuthorisedValues($mss->next->authorised_value);
211
    if ($materials_authvals) {
214
    if ($materials_authvals) {
212
        foreach my $value (@$materials_authvals) {
215
        foreach my $value (@$materials_authvals) {
213
            $materials_map{$value->{authorised_value}} = $value->{lib};
216
            $materials_map{$value->{authorised_value}} = $value->{lib};
(-)a/catalogue/getitem-ajax.pl (-20 / +11 lines)
Lines 55-84 if($itemnumber) { Link Here
55
        $item->{holdingbranchname} = GetBranchName($item->{holdingbranch});
55
        $item->{holdingbranchname} = GetBranchName($item->{holdingbranch});
56
    }
56
    }
57
57
58
    if(my $code = GetAuthValCode("items.notforloan", $fw)) {
58
    my $av;
59
        my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{notforloan} });
59
    $av = Koha::AuthorisedValues->search_by_koha_field({ frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} });
60
        $item->{notforloan} = $av->count ? $av->next->lib : '';
60
    $item->{notforloan} = $av->count ? $av->next->lib : '';
61
    }
62
61
63
    if(my $code = GetAuthValCode("items.restricted", $fw)) {
62
    $av = Koha::AuthorisedValues->search_by_koha_field({ frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} });
64
        my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{restricted} });
63
    $item->{restricted} = $av->count ? $av->next->lib : '';
65
        $item->{restricted} = $av->count ? $av->next->lib : '';
66
    }
67
64
68
    if(my $code = GetAuthValCode("items.location", $fw)) {
65
    $av = Koha::AuthorisedValues->search_by_koha_field({ frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} });
69
        my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{location} });
66
    $item->{location} = $av->count ? $av->next->lib : '';
70
        $item->{location} = $av->count ? $av->next->lib : '';
71
    }
72
67
73
    if(my $code = GetAuthValCode("items.ccode", $fw)) {
68
    $av = Koha::AuthorisedValues->search_by_koha_field({ frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} });
74
        my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{collection} });
69
    $item->{collection} = $av->count ? $av->next->lib : '';
75
        $item->{collection} = $av->count ? $av->next->lib : '';
76
    }
77
70
78
    if(my $code = GetAuthValCode("items.materials", $fw)) {
71
    $av = Koha::AuthorisedValues->search_by_koha_field({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
79
        my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{materials} });
72
    $item->{materials} = $av->count ? $av->next->lib : '';
80
        $item->{materials} = $av->count ? $av->next->lib : '';
81
    }
82
73
83
    my $itemtype = getitemtypeinfo($item->{itype});
74
    my $itemtype = getitemtypeinfo($item->{itype});
84
    $item->{itemtype} = $itemtype->{description};
75
    $item->{itemtype} = $itemtype->{description};
(-)a/catalogue/itemsearch.pl (-5 / +8 lines)
Lines 28-33 use C4::Biblio; Link Here
28
use C4::Branch;
28
use C4::Branch;
29
use C4::Koha;
29
use C4::Koha;
30
30
31
use Koha::AuthorisedValues;
31
use Koha::Item::Search::Field qw(GetItemSearchFields);
32
use Koha::Item::Search::Field qw(GetItemSearchFields);
32
use Koha::ItemTypes;
33
use Koha::ItemTypes;
33
34
Lines 87-97 my ($template, $borrowernumber, $cookie) = get_template_and_user({ Link Here
87
    flagsrequired   => { catalogue => 1 },
88
    flagsrequired   => { catalogue => 1 },
88
});
89
});
89
90
90
my $notforloan_avcode = GetAuthValCode('items.notforloan');
91
my $mss = Koha::MarcSubfieldStructure->search({ frameworkcode => '', kohafield => 'items.notforloan' });
91
my $notforloan_values = GetAuthorisedValues($notforloan_avcode);
92
my $notforloan_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : [];
92
93
93
my $location_avcode = GetAuthValCode('items.location');
94
$mss = Koha::MarcSubfieldStructure->search({ frameworkcode => '', kohafield => 'items.location' });
94
my $location_values = GetAuthorisedValues($location_avcode);
95
my $location_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : [];
95
96
96
if (scalar keys %params > 0) {
97
if (scalar keys %params > 0) {
97
    # Parameters given, it's a search
98
    # Parameters given, it's a search
Lines 269-275 if ($format eq 'html') { Link Here
269
            label => $itemtype->translated_description,
270
            label => $itemtype->translated_description,
270
        };
271
        };
271
    }
272
    }
272
    my $ccode_avcode = GetAuthValCode('items.ccode') || 'CCODE';
273
274
    my $mss = Koha::MarcSubfieldStructure->search({ frameworkcode => '', kohafield => 'items.ccode' });
275
    my $ccode_avcode = $mss->count ? $mss->next->authorised_value : 'CCODE';
273
    my $ccodes = GetAuthorisedValues($ccode_avcode);
276
    my $ccodes = GetAuthorisedValues($ccode_avcode);
274
    my @ccodes;
277
    my @ccodes;
275
    foreach my $ccode (@$ccodes) {
278
    foreach my $ccode (@$ccodes) {
(-)a/catalogue/moredetail.pl (-6 / +10 lines)
Lines 37-42 use C4::Members qw/GetHideLostItemsPreference/; Link Here
37
use C4::Reserves qw(GetReservesFromBiblionumber);
37
use C4::Reserves qw(GetReservesFromBiblionumber);
38
38
39
use Koha::Acquisition::Bookseller;
39
use Koha::Acquisition::Bookseller;
40
use Koha::AuthorisedValues;
40
use Koha::DateUtils;
41
use Koha::DateUtils;
41
use Koha::Items;
42
use Koha::Items;
42
43
Lines 196-209 foreach my $item (@items){ Link Here
196
197
197
}
198
}
198
199
199
if ( my $lost_av = GetAuthValCode('items.itemlost', $fw) ) {
200
my $mss = Koha::MarcSubfieldStructure->search({ frameworkcode => $fw, kohafield => 'items.itemlost' });
200
    $template->param( itemlostloop => GetAuthorisedValues( $lost_av ) );
201
if ( $mss->count ) {
202
    $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorisedvalue ) );
201
}
203
}
202
if ( my $damaged_av = GetAuthValCode('items.damaged', $fw) ) {
204
$mss = Koha::MarcSubfieldStructure->search({ frameworkcode => $fw, kohafield => 'items.damaged' });
203
    $template->param( itemdamagedloop => GetAuthorisedValues( $damaged_av ) );
205
if ( $mss->count ) {
206
    $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorisedvalue ) );
204
}
207
}
205
if ( my $withdrawn_av = GetAuthValCode('items.withdrawn', $fw) ) {
208
$mss = Koha::MarcSubfieldStructure->search({ frameworkcode => $fw, kohafield => 'items.withdrawn' });
206
    $template->param( itemwithdrawnloop => GetAuthorisedValues( $withdrawn_av ) );
209
if ( $mss->count ) {
210
    $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorisedvalue) );
207
}
211
}
208
212
209
$template->param(count => $data->{'count'},
213
$template->param(count => $data->{'count'},
(-)a/circ/circulation.pl (-7 / +5 lines)
Lines 338-345 if (@$barcodes) { Link Here
338
338
339
    #  Get the item title for more information
339
    #  Get the item title for more information
340
    my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode);
340
    my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode);
341
    $template_params->{authvalcode_notforloan} =
341
342
        C4::Koha::GetAuthValCode('items.notforloan', $getmessageiteminfo->{'frameworkcode'});
342
    my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $getmessageiteminfo->{frameworkcode}, kohafield => 'items.notforloan' });
343
    $template_params->{authvalcode_notforloan} = $mss->count ? $mss->next->authorisedvalue : undef;
343
344
344
    # Fix for bug 7494: optional checkout-time fallback search for a book
345
    # Fix for bug 7494: optional checkout-time fallback search for a book
345
346
Lines 388-398 if (@$barcodes) { Link Here
388
        unless($issueconfirmed){
389
        unless($issueconfirmed){
389
            #  Get the item title for more information
390
            #  Get the item title for more information
390
            my $materials = $iteminfo->{'materials'};
391
            my $materials = $iteminfo->{'materials'};
391
            my $avcode = GetAuthValCode('items.materials');
392
            my $av = Koha::AuthorisedValues->search_by_koha_field({ frameworkcode => $getmessageiteminfo->{frameworkcode}, kohafield => 'items.materials', authorised_value => $materials });
392
            if ($avcode) {
393
            $materials = $av->count ? $av->next->lib : '';
393
                my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials });
394
                $materials = $av->count ? $av->next->lib : '';
395
            }
396
            $template_params->{additional_materials} = $materials;
394
            $template_params->{additional_materials} = $materials;
397
            $template_params->{itemhomebranch} = $iteminfo->{'homebranch'};
395
            $template_params->{itemhomebranch} = $iteminfo->{'homebranch'};
398
396
(-)a/circ/returns.pl (-5 / +2 lines)
Lines 281-291 if ($barcode) { Link Here
281
    $returnbranch = $biblio->{$hbr};
281
    $returnbranch = $biblio->{$hbr};
282
282
283
    my $materials = $biblio->{'materials'};
283
    my $materials = $biblio->{'materials'};
284
    my $avcode = GetAuthValCode('items.materials');
284
    my $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
285
    if ($avcode) {
285
    $materials = $av->count ? $av->next->lib : '';
286
        my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials });
287
        $materials = $av->count ? $av->next->lib : '';
288
    }
289
286
290
    $template->param(
287
    $template->param(
291
        title            => $biblio->{'title'},
288
        title            => $biblio->{'title'},
(-)a/t/db_dependent/AuthorisedValues.t (-1 / +10 lines)
Lines 102-108 is( $categories[0], $av4->category, 'The first category should be correct (order Link Here
102
is( $categories[1], $av1->category, 'The second category should be correct (ordered by category name)' );
102
is( $categories[1], $av1->category, 'The second category should be correct (ordered by category name)' );
103
103
104
subtest 'search_by_*_field' => sub {
104
subtest 'search_by_*_field' => sub {
105
    plan tests => 1;
105
    plan tests => 2;
106
    my $loc_cat = Koha::AuthorisedValueCategories->find('LOC');
106
    my $loc_cat = Koha::AuthorisedValueCategories->find('LOC');
107
    $loc_cat->delete if $loc_cat;
107
    $loc_cat->delete if $loc_cat;
108
    my $mss = Koha::MarcSubfieldStructures->search( { tagfield => 952, tagsubfield => 'c', frameworkcode => '' } );
108
    my $mss = Koha::MarcSubfieldStructures->search( { tagfield => 952, tagsubfield => 'c', frameworkcode => '' } );
Lines 130-133 subtest 'search_by_*_field' => sub { Link Here
130
        is( $avs->count, 3, 'default fk');
130
        is( $avs->count, 3, 'default fk');
131
        is( $avs->next->authorised_value, 'location_1', );
131
        is( $avs->next->authorised_value, 'location_1', );
132
    };
132
    };
133
    subtest 'search_by_koha_field' => sub {
134
        plan tests => 3;
135
        my $avs;
136
        $avs = Koha::AuthorisedValues->search_by_koha_field();
137
        is ( $avs, undef );
138
        $avs = Koha::AuthorisedValues->search_by_koha_field( { kohafield => 'items.location', tagfield => 952, tagsubfield => 'c' } );
139
        is( $avs->count,                  3, );
140
        is( $avs->next->authorised_value, 'location_1', );
141
    };
133
};
142
};
(-)a/tools/inventory.pl (-3 / +4 lines)
Lines 83-89 $frameworks->{''} = {frameworkcode => ''}; # Add the default framework Link Here
83
83
84
for my $fwk (keys %$frameworks){
84
for my $fwk (keys %$frameworks){
85
  my $fwkcode = $frameworks->{$fwk}->{'frameworkcode'};
85
  my $fwkcode = $frameworks->{$fwk}->{'frameworkcode'};
86
  my $authcode = GetAuthValCode('items.location', $fwkcode);
86
  my $mss = Koha::MarcSubfieldStructure->search({ frameworkcode => $fwkcode, kohafield => 'items.location' });
87
  my $authcode = $mss->count ? $mss->next->authorised_value : undef;
87
    if ($authcode && $authorisedvalue_categories!~/\b$authcode\W/){
88
    if ($authcode && $authorisedvalue_categories!~/\b$authcode\W/){
88
      $authorisedvalue_categories.="$authcode ";
89
      $authorisedvalue_categories.="$authcode ";
89
      my $data=GetAuthorisedValues($authcode);
90
      my $data=GetAuthorisedValues($authcode);
Lines 98-104 my $statuses = []; Link Here
98
for my $statfield (qw/items.notforloan items.itemlost items.withdrawn items.damaged/){
99
for my $statfield (qw/items.notforloan items.itemlost items.withdrawn items.damaged/){
99
    my $hash = {};
100
    my $hash = {};
100
    $hash->{fieldname} = $statfield;
101
    $hash->{fieldname} = $statfield;
101
    $hash->{authcode} = GetAuthValCode($statfield);
102
    my $mss = Koha::MarcSubfieldStructure->search({ frameworkcode => '', kohafield => $statfield });
103
    $hash->{authcode} = $mss->count ? $mss->next->authorised_value : undef;
102
    if ($hash->{authcode}){
104
    if ($hash->{authcode}){
103
        my $arr = GetAuthorisedValues($hash->{authcode});
105
        my $arr = GetAuthorisedValues($hash->{authcode});
104
        $hash->{values} = $arr;
106
        $hash->{values} = $arr;
105
- 

Return to bug 17250