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

(-)a/C4/Circulation.pm (-1 lines)
Lines 36-42 use C4::Debug; Link Here
36
use C4::Log; # logaction
36
use C4::Log; # logaction
37
use C4::Koha qw(
37
use C4::Koha qw(
38
    GetAuthorisedValueByCode
38
    GetAuthorisedValueByCode
39
    GetAuthValCode
40
);
39
);
41
use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units);
40
use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units);
42
use C4::RotatingCollections qw(GetCollectionItemBranches);
41
use C4::RotatingCollections qw(GetCollectionItemBranches);
(-)a/C4/Items.pm (-16 / +11 lines)
Lines 1381-1407 sub GetItemsInfo { Link Here
1381
1381
1382
        $serial ||= $data->{'serial'};
1382
        $serial ||= $data->{'serial'};
1383
1383
1384
        my $av;
1384
        # get notforloan complete status if applicable
1385
        # get notforloan complete status if applicable
1385
        if ( my $code = C4::Koha::GetAuthValCode( 'items.notforloan', $data->{frameworkcode} ) ) {
1386
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.notforloan', authorised_value => $data->{itemnotforloan} });
1386
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{itemnotforloan} });
1387
        $av = $av->count ? $av->next : undef;
1387
            $av = $av->count ? $av->next : undef;
1388
        $data->{notforloanvalue}     = $av ? $av->lib : '';
1388
            $data->{notforloanvalue}     = $av ? $av->lib : '';
1389
        $data->{notforloanvalueopac} = $av ? $av->opac_description : '';
1389
            $data->{notforloanvalueopac} = $av ? $av->opac_description : '';
1390
        }
1391
1390
1392
        # get restricted status and description if applicable
1391
        # get restricted status and description if applicable
1393
        if ( my $code = C4::Koha::GetAuthValCode( 'items.restricted', $data->{frameworkcode} ) ) {
1392
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.restricted', authorised_value => $data->{restricted} });
1394
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{restricted} });
1393
        $av = $av->count ? $av->next : undef;
1395
            $av = $av->count ? $av->next : undef;
1394
        $data->{restricted}     = $av ? $av->lib : '';
1396
            $data->{restricted}     = $av ? $av->lib : '';
1395
        $data->{restrictedopac} = $av ? $av->opac_description : '';
1397
            $data->{restrictedopac} = $av ? $av->opac_description : '';
1398
        }
1399
1396
1400
        # my stack procedures
1397
        # my stack procedures
1401
        if ( my $code = C4::Koha::GetAuthValCode( 'items.stack', $data->{frameworkcode} ) ) {
1398
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $data->{frameworkcode}, kohafield => 'items.stack', authorised_value => $data->{stack} });
1402
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{stack} });
1399
        $data->{stack}          = $av->count ? $av->next->lib : '';
1403
            $data->{stack}          = $av->count ? $av->next->lib : '';
1404
        }
1405
1400
1406
        # Find the last 3 people who borrowed this item.
1401
        # Find the last 3 people who borrowed this item.
1407
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
1402
        my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers
(-)a/C4/Koha.pm (-32 / +12 lines)
Lines 56-62 BEGIN { Link Here
56
		&GetKohaAuthorisedValues
56
		&GetKohaAuthorisedValues
57
    &GetKohaAuthorisedValuesMapping
57
    &GetKohaAuthorisedValuesMapping
58
    &GetAuthorisedValueByCode
58
    &GetAuthorisedValueByCode
59
		&GetAuthValCode
60
		&GetNormalizedUPC
59
		&GetNormalizedUPC
61
		&GetNormalizedISBN
60
		&GetNormalizedISBN
62
		&GetNormalizedEAN
61
		&GetNormalizedEAN
Lines 880-901 SELECT lib, Link Here
880
    return \%notforloan_label_of;
879
    return \%notforloan_label_of;
881
}
880
}
882
881
883
=head2 GetAuthValCode
884
885
  $authvalcode = GetAuthValCode($kohafield,$frameworkcode);
886
887
=cut
888
889
sub GetAuthValCode {
890
	my ($kohafield,$fwcode) = @_;
891
	my $dbh = C4::Context->dbh;
892
	$fwcode='' unless $fwcode;
893
	my $sth = $dbh->prepare('select authorised_value from marc_subfield_structure where kohafield=? and frameworkcode=?');
894
	$sth->execute($kohafield,$fwcode);
895
	my ($authvalcode) = $sth->fetchrow_array;
896
	return $authvalcode;
897
}
898
899
=head2 GetAuthorisedValues
882
=head2 GetAuthorisedValues
900
883
901
  $authvalues = GetAuthorisedValues([$category]);
884
  $authvalues = GetAuthorisedValues([$category]);
Lines 1017-1037 Returns undef if no authorised value category is defined for the kohafield. Link Here
1017
=cut
1000
=cut
1018
1001
1019
sub GetKohaAuthorisedValues {
1002
sub GetKohaAuthorisedValues {
1020
  my ($kohafield,$fwcode,$opac) = @_;
1003
    my ( $kohafield, $fwcode, $opac ) = @_;
1021
  $fwcode='' unless $fwcode;
1004
    $fwcode = '' unless $fwcode;
1022
  my %values;
1005
    my %values;
1023
  my $dbh = C4::Context->dbh;
1006
    my $dbh = C4::Context->dbh;
1024
  my $avcode = GetAuthValCode($kohafield,$fwcode);
1007
1025
  if ($avcode) {  
1008
    my $avs = Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fwcode, kohafield => $kohafield } );
1026
	my $sth = $dbh->prepare("select authorised_value, lib, lib_opac from authorised_values where category=? ");
1009
    return {} unless $avs->count;
1027
   	$sth->execute($avcode);
1010
    my $values;
1028
	while ( my ($val, $lib, $lib_opac) = $sth->fetchrow_array ) { 
1011
    while ( my $av = $avs->next ) {
1029
		$values{$val} = ($opac && $lib_opac) ? $lib_opac : $lib;
1012
        $values->{ $av->authorised_value } = $opac ? $av->opac_description : $av->lib;
1030
   	}
1013
    }
1031
   	return \%values;
1014
    return $values;
1032
  } else {
1033
	return;
1034
  }
1035
}
1015
}
1036
1016
1037
=head2 GetKohaAuthorisedValuesMapping
1017
=head2 GetKohaAuthorisedValuesMapping
(-)a/C4/Search.pm (-1 / +2 lines)
Lines 1852-1858 sub searchResults { Link Here
1852
    my $shelflocations =GetKohaAuthorisedValues('items.location','');
1852
    my $shelflocations =GetKohaAuthorisedValues('items.location','');
1853
1853
1854
    # get notforloan authorised value list (see $shelflocations  FIXME)
1854
    # get notforloan authorised value list (see $shelflocations  FIXME)
1855
    my $notforloan_authorised_value = GetAuthValCode('items.notforloan','');
1855
    my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan' });
1856
    my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef;
1856
1857
1857
    #Get itemtype hash
1858
    #Get itemtype hash
1858
    my %itemtypes = %{ GetItemTypes() };
1859
    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 128-153 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
        if(my $code = GetAuthValCode("items.notforloan", $fw)) {
131
        my $av;
132
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{notforloan} });
132
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} });
133
            $item->{notforloan} = $av->count ? $av->next->lib : '';
133
        $item->{notforloan} = $av->count ? $av->next->lib : '';
134
        }
134
135
        if(my $code = GetAuthValCode("items.restricted", $fw)) {
135
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} });
136
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{restricted} });
136
        $item->{restricted} = $av->count ? $av->next->lib : '';
137
            $item->{restricted} = $av->count ? $av->next->lib : '';
137
138
        }
138
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} });
139
        if(my $code = GetAuthValCode("items.location", $fw)) {
139
        $item->{location} = $av->count ? $av->next->lib : '';
140
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{location} });
140
141
            $item->{location} = $av->count ? $av->next->lib : '';
141
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} });
142
        }
142
        $item->{collection} = $av->count ? $av->next->lib : '';
143
        if(my $code = GetAuthValCode("items.ccode", $fw)) {
143
144
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{collection} });
144
        $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
145
            $item->{collection} = $av->count ? $av->next->lib : '';
145
        $item->{materials} = $av->count ? $av->next->lib : '';
146
        }
146
147
        if(my $code = GetAuthValCode("items.materials", $fw)) {
148
            my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{materials} });
149
            $item->{materials} = $av->count ? $av->next->lib : '';
150
        }
151
        my $itemtype = getitemtypeinfo($item->{itype});
147
        my $itemtype = getitemtypeinfo($item->{itype});
152
        $item->{itemtype} = $itemtype->{description};
148
        $item->{itemtype} = $itemtype->{description};
153
        push @items, $item;
149
        push @items, $item;
(-)a/catalogue/detail.pl (-7 / +10 lines)
Lines 41-46 use Koha::DateUtils; Link Here
41
use C4::HTML5Media;
41
use C4::HTML5Media;
42
use C4::CourseReserves qw(GetItemCourseReservesInfo);
42
use C4::CourseReserves qw(GetItemCourseReservesInfo);
43
use C4::Acquisition qw(GetOrdersByBiblionumber);
43
use C4::Acquisition qw(GetOrdersByBiblionumber);
44
use Koha::AuthorisedValues;
44
use Koha::Virtualshelves;
45
use Koha::Virtualshelves;
45
46
46
my $query = CGI->new();
47
my $query = CGI->new();
Lines 194-210 my $copynumbers = GetKohaAuthorisedValues('items.copynumber', $fw); Link Here
194
my (@itemloop, @otheritemloop, %itemfields);
195
my (@itemloop, @otheritemloop, %itemfields);
195
my $norequests = 1;
196
my $norequests = 1;
196
197
197
if ( my $lost_av = GetAuthValCode('items.itemlost', $fw) ) {
198
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost' });
198
    $template->param( itemlostloop => GetAuthorisedValues( $lost_av ) );
199
if ( $mss->count ) {
200
    $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) );
199
}
201
}
200
if ( my $damaged_av = GetAuthValCode('items.damaged', $fw) ) {
202
$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged' });
201
    $template->param( itemdamagedloop => GetAuthorisedValues( $damaged_av ) );
203
if ( $mss->count ) {
204
    $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) );
202
}
205
}
203
206
204
my $materials_authvalcode = GetAuthValCode('items.materials', $fw);
207
$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials' });
205
my %materials_map;
208
my %materials_map;
206
if ($materials_authvalcode) {
209
if ($mss->count) {
207
    my $materials_authvals = GetAuthorisedValues($materials_authvalcode);
210
    my $materials_authvals = GetAuthorisedValues($mss->next->authorised_value);
208
    if ($materials_authvals) {
211
    if ($materials_authvals) {
209
        foreach my $value (@$materials_authvals) {
212
        foreach my $value (@$materials_authvals) {
210
            $materials_map{$value->{authorised_value}} = $value->{lib};
213
            $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} = Koha::Libraries->find($item->{holdingbranch})->branchname;
55
        $item->{holdingbranchname} = Koha::Libraries->find($item->{holdingbranch})->branchname;
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 27-32 use C4::Items; Link Here
27
use C4::Biblio;
27
use C4::Biblio;
28
use C4::Koha;
28
use C4::Koha;
29
29
30
use Koha::AuthorisedValues;
30
use Koha::Item::Search::Field qw(GetItemSearchFields);
31
use Koha::Item::Search::Field qw(GetItemSearchFields);
31
use Koha::ItemTypes;
32
use Koha::ItemTypes;
32
use Koha::Libraries;
33
use Koha::Libraries;
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::MarcSubfieldStructures->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::MarcSubfieldStructures->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 262-268 if ($format eq 'html') { Link Here
262
            label => $itemtype->translated_description,
263
            label => $itemtype->translated_description,
263
        };
264
        };
264
    }
265
    }
265
    my $ccode_avcode = GetAuthValCode('items.ccode') || 'CCODE';
266
267
    my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.ccode' });
268
    my $ccode_avcode = $mss->count ? $mss->next->authorised_value : 'CCODE';
266
    my $ccodes = GetAuthorisedValues($ccode_avcode);
269
    my $ccodes = GetAuthorisedValues($ccode_avcode);
267
    my @ccodes;
270
    my @ccodes;
268
    foreach my $ccode (@$ccodes) {
271
    foreach my $ccode (@$ccodes) {
(-)a/catalogue/moredetail.pl (-6 / +10 lines)
Lines 36-41 use C4::Members qw/GetHideLostItemsPreference/; Link Here
36
use C4::Reserves qw(GetReservesFromBiblionumber);
36
use C4::Reserves qw(GetReservesFromBiblionumber);
37
37
38
use Koha::Acquisition::Bookseller;
38
use Koha::Acquisition::Bookseller;
39
use Koha::AuthorisedValues;
39
use Koha::DateUtils;
40
use Koha::DateUtils;
40
use Koha::Items;
41
use Koha::Items;
41
42
Lines 193-206 foreach my $item (@items){ Link Here
193
194
194
}
195
}
195
196
196
if ( my $lost_av = GetAuthValCode('items.itemlost', $fw) ) {
197
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost' });
197
    $template->param( itemlostloop => GetAuthorisedValues( $lost_av ) );
198
if ( $mss->count ) {
199
    $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorisedvalue ) );
198
}
200
}
199
if ( my $damaged_av = GetAuthValCode('items.damaged', $fw) ) {
201
$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged' });
200
    $template->param( itemdamagedloop => GetAuthorisedValues( $damaged_av ) );
202
if ( $mss->count ) {
203
    $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorisedvalue ) );
201
}
204
}
202
if ( my $withdrawn_av = GetAuthValCode('items.withdrawn', $fw) ) {
205
$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.withdrawn' });
203
    $template->param( itemwithdrawnloop => GetAuthorisedValues( $withdrawn_av ) );
206
if ( $mss->count ) {
207
    $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorisedvalue) );
204
}
208
}
205
209
206
$template->param(count => $data->{'count'},
210
$template->param(count => $data->{'count'},
(-)a/circ/circulation.pl (-7 / +5 lines)
Lines 340-347 if (@$barcodes) { Link Here
340
340
341
    #  Get the item title for more information
341
    #  Get the item title for more information
342
    my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode);
342
    my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode);
343
    $template_params->{authvalcode_notforloan} =
343
344
        C4::Koha::GetAuthValCode('items.notforloan', $getmessageiteminfo->{'frameworkcode'});
344
    my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $getmessageiteminfo->{frameworkcode}, kohafield => 'items.notforloan' });
345
    $template_params->{authvalcode_notforloan} = $mss->count ? $mss->next->authorisedvalue : undef;
345
346
346
    # Fix for bug 7494: optional checkout-time fallback search for a book
347
    # Fix for bug 7494: optional checkout-time fallback search for a book
347
348
Lines 390-400 if (@$barcodes) { Link Here
390
        unless($issueconfirmed){
391
        unless($issueconfirmed){
391
            #  Get the item title for more information
392
            #  Get the item title for more information
392
            my $materials = $iteminfo->{'materials'};
393
            my $materials = $iteminfo->{'materials'};
393
            my $avcode = GetAuthValCode('items.materials');
394
            my $av = Koha::AuthorisedValues->search_by_koha_field({ frameworkcode => $getmessageiteminfo->{frameworkcode}, kohafield => 'items.materials', authorised_value => $materials });
394
            if ($avcode) {
395
            $materials = $av->count ? $av->next->lib : '';
395
                my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials });
396
                $materials = $av->count ? $av->next->lib : '';
397
            }
398
            $template_params->{additional_materials} = $materials;
396
            $template_params->{additional_materials} = $materials;
399
            $template_params->{itemhomebranch} = $iteminfo->{'homebranch'};
397
            $template_params->{itemhomebranch} = $iteminfo->{'homebranch'};
400
398
(-)a/circ/returns.pl (-5 / +2 lines)
Lines 279-289 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 $avcode = GetAuthValCode('items.materials');
282
    my $av = Koha::AuthorisedValues->search_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
283
    if ($avcode) {
283
    $materials = $av->count ? $av->next->lib : '';
284
        my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials });
285
        $materials = $av->count ? $av->next->lib : '';
286
    }
287
284
288
    $template->param(
285
    $template->param(
289
        title            => $biblio->{'title'},
286
        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 72-78 $frameworks->{''} = {frameworkcode => ''}; # Add the default framework Link Here
72
72
73
for my $fwk (keys %$frameworks){
73
for my $fwk (keys %$frameworks){
74
  my $fwkcode = $frameworks->{$fwk}->{'frameworkcode'};
74
  my $fwkcode = $frameworks->{$fwk}->{'frameworkcode'};
75
  my $authcode = GetAuthValCode('items.location', $fwkcode);
75
  my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fwkcode, kohafield => 'items.location' });
76
  my $authcode = $mss->count ? $mss->next->authorised_value : undef;
76
    if ($authcode && $authorisedvalue_categories!~/\b$authcode\W/){
77
    if ($authcode && $authorisedvalue_categories!~/\b$authcode\W/){
77
      $authorisedvalue_categories.="$authcode ";
78
      $authorisedvalue_categories.="$authcode ";
78
      my $data=GetAuthorisedValues($authcode);
79
      my $data=GetAuthorisedValues($authcode);
Lines 87-93 my $statuses = []; Link Here
87
for my $statfield (qw/items.notforloan items.itemlost items.withdrawn items.damaged/){
88
for my $statfield (qw/items.notforloan items.itemlost items.withdrawn items.damaged/){
88
    my $hash = {};
89
    my $hash = {};
89
    $hash->{fieldname} = $statfield;
90
    $hash->{fieldname} = $statfield;
90
    $hash->{authcode} = GetAuthValCode($statfield);
91
    my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => $statfield });
92
    $hash->{authcode} = $mss->count ? $mss->next->authorised_value : undef;
91
    if ($hash->{authcode}){
93
    if ($hash->{authcode}){
92
        my $arr = GetAuthorisedValues($hash->{authcode});
94
        my $arr = GetAuthorisedValues($hash->{authcode});
93
        $hash->{values} = $arr;
95
        $hash->{values} = $arr;
94
- 

Return to bug 17250