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

(-)a/C4/Koha.pm (-28 lines)
Lines 54-60 BEGIN { Link Here
54
		&getitemtypeimagelocation
54
		&getitemtypeimagelocation
55
		&GetAuthorisedValues
55
		&GetAuthorisedValues
56
		&GetAuthorisedValueCategories
56
		&GetAuthorisedValueCategories
57
		&GetKohaAuthorisedValues
58
		&GetNormalizedUPC
57
		&GetNormalizedUPC
59
		&GetNormalizedISBN
58
		&GetNormalizedISBN
60
		&GetNormalizedEAN
59
		&GetNormalizedEAN
Lines 965-997 sub GetAuthorisedValueCategories { Link Here
965
    return \@results;
964
    return \@results;
966
}
965
}
967
966
968
=head2 GetKohaAuthorisedValues
969
970
Takes $kohafield, $fwcode as parameters.
971
972
If $opac parameter is set to a true value, displays OPAC descriptions rather than normal ones when they exist.
973
974
Returns hashref of Code => description
975
976
Returns undef if no authorised value category is defined for the kohafield.
977
978
=cut
979
980
sub GetKohaAuthorisedValues {
981
    my ( $kohafield, $fwcode, $opac ) = @_;
982
    $fwcode = '' unless $fwcode;
983
    my %values;
984
    my $dbh = C4::Context->dbh;
985
986
    my $avs = Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fwcode, kohafield => $kohafield } );
987
    return {} unless $avs->count;
988
    my $values;
989
    while ( my $av = $avs->next ) {
990
        $values->{ $av->authorised_value } = $opac ? $av->opac_description : $av->lib;
991
    }
992
    return $values;
993
}
994
995
=head2 xml_escape
967
=head2 xml_escape
996
968
997
  my $escaped_string = C4::Koha::xml_escape($string);
969
  my $escaped_string = C4::Koha::xml_escape($string);
(-)a/C4/Search.pm (-1 / +2 lines)
Lines 1849-1855 sub searchResults { Link Here
1849
# FIXME - We build an authorised values hash here, using the default framework
1849
# FIXME - We build an authorised values hash here, using the default framework
1850
# though it is possible to have different authvals for different fws.
1850
# though it is possible to have different authvals for different fws.
1851
1851
1852
    my $shelflocations =GetKohaAuthorisedValues('items.location','');
1852
    my $shelflocations =
1853
      { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
1853
1854
1854
    # get notforloan authorised value list (see $shelflocations  FIXME)
1855
    # get notforloan authorised value list (see $shelflocations  FIXME)
1855
    my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan', authorised_value => { not => undef } });
1856
    my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan', authorised_value => { not => undef } });
(-)a/C4/XSLT.pm (-2 / +5 lines)
Lines 29-34 use C4::Koha; Link Here
29
use C4::Biblio;
29
use C4::Biblio;
30
use C4::Circulation;
30
use C4::Circulation;
31
use C4::Reserves;
31
use C4::Reserves;
32
use Koha::AuthorisedValues;
32
use Koha::XSLT_Handler;
33
use Koha::XSLT_Handler;
33
use Koha::Libraries;
34
use Koha::Libraries;
34
35
Lines 272-279 sub buildKohaItemsNamespace { Link Here
272
        @items = grep { !$hi{$_->{itemnumber}} } @items;
273
        @items = grep { !$hi{$_->{itemnumber}} } @items;
273
    }
274
    }
274
275
275
    my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
276
    my $shelflocations =
276
    my $ccodes         = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
277
      { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => GetFrameworkCode($biblionumber), kohafield => 'items.location' } ) };
278
    my $ccodes =
279
      { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => GetFrameworkCode($biblionumber), kohafield => 'items.ccode' } ) };
277
280
278
    my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' });
281
    my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' });
279
282
(-)a/acqui/orderreceive.pl (-1 / +1 lines)
Lines 63-69 use warnings; Link Here
63
63
64
use CGI qw ( -utf8 );
64
use CGI qw ( -utf8 );
65
use C4::Context;
65
use C4::Context;
66
use C4::Koha;   # GetKohaAuthorisedValues GetItemTypes
66
use C4::Koha;   # GetItemTypes
67
use C4::Acquisition;
67
use C4::Acquisition;
68
use C4::Auth;
68
use C4::Auth;
69
use C4::Output;
69
use C4::Output;
(-)a/basket/basket.pl (-2 / +3 lines)
Lines 24-29 use C4::Items; Link Here
24
use C4::Auth;
24
use C4::Auth;
25
use C4::Output;
25
use C4::Output;
26
26
27
use Koha::AuthorisedValues;
27
use Koha::CsvProfiles;
28
use Koha::CsvProfiles;
28
29
29
my $query = new CGI;
30
my $query = new CGI;
Lines 75-82 foreach my $biblionumber ( @bibs ) { Link Here
75
      $hasauthors = 1;
76
      $hasauthors = 1;
76
    }
77
    }
77
	
78
	
78
    my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'});
79
    my $shelflocations =
79
    my $collections =  GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'});
80
      { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
80
81
81
	for my $itm (@items) {
82
	for my $itm (@items) {
82
	    if ($itm->{'location'}){
83
	    if ($itm->{'location'}){
(-)a/catalogue/detail.pl (-3 / +6 lines)
Lines 189-197 $dat->{'count'} = scalar @all_items + @hostitems; Link Here
189
$dat->{'showncount'} = scalar @items + @hostitems;
189
$dat->{'showncount'} = scalar @items + @hostitems;
190
$dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items;
190
$dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items;
191
191
192
my $shelflocations = GetKohaAuthorisedValues('items.location', $fw);
192
my $shelflocations =
193
my $collections    = GetKohaAuthorisedValues('items.ccode'   , $fw);
193
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) };
194
my $copynumbers    = GetKohaAuthorisedValues('items.copynumber', $fw);
194
my $collections =
195
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
196
my $copynumbers =
197
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
195
my (@itemloop, @otheritemloop, %itemfields);
198
my (@itemloop, @otheritemloop, %itemfields);
196
my $norequests = 1;
199
my $norequests = 1;
197
200
(-)a/catalogue/moredetail.pl (-2 / +4 lines)
Lines 119-126 $data->{'count'}=$totalcount; Link Here
119
$data->{'showncount'}=$showncount;
119
$data->{'showncount'}=$showncount;
120
$data->{'hiddencount'}=$hiddencount;  # can be zero
120
$data->{'hiddencount'}=$hiddencount;  # can be zero
121
121
122
my $ccodes= GetKohaAuthorisedValues('items.ccode',$fw);
122
my $ccodes =
123
my $copynumbers = GetKohaAuthorisedValues('items.copynumber',$fw);
123
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
124
my $copynumbers =
125
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
124
my $itemtypes = GetItemTypes;
126
my $itemtypes = GetItemTypes;
125
127
126
$data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'translated_description'};
128
$data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'translated_description'};
(-)a/circ/returns.pl (-1 / +2 lines)
Lines 551-557 $template->param( errmsgloop => \@errmsgloop ); Link Here
551
my $returned_counter = ( C4::Context->preference('numReturnedItemsToShow') ) ? C4::Context->preference('numReturnedItemsToShow') : 8;
551
my $returned_counter = ( C4::Context->preference('numReturnedItemsToShow') ) ? C4::Context->preference('numReturnedItemsToShow') : 8;
552
my $count = 0;
552
my $count = 0;
553
my @riloop;
553
my @riloop;
554
my $shelflocations = GetKohaAuthorisedValues('items.location','');
554
my $shelflocations =
555
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
555
foreach ( sort { $a <=> $b } keys %returneditems ) {
556
foreach ( sort { $a <=> $b } keys %returneditems ) {
556
    my %ri;
557
    my %ri;
557
    if ( $count++ < $returned_counter ) {
558
    if ( $count++ < $returned_counter ) {
(-)a/opac/opac-basket.pl (-2 / +6 lines)
Lines 26-31 use C4::Auth; Link Here
26
use C4::Output;
26
use C4::Output;
27
use Koha::RecordProcessor;
27
use Koha::RecordProcessor;
28
28
29
use Koha::AuthorisedValues;
30
29
my $query = new CGI;
31
my $query = new CGI;
30
32
31
my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
33
my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
Lines 83-90 foreach my $biblionumber ( @bibs ) { Link Here
83
    if($dat->{'author'} || @$marcauthorsarray) {
85
    if($dat->{'author'} || @$marcauthorsarray) {
84
      $hasauthors = 1;
86
      $hasauthors = 1;
85
    }
87
    }
86
    my $collections =  GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
88
    my $collections =
87
    my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
89
      { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.ccode' } ) };
90
    my $shelflocations =
91
      { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
88
92
89
	# COinS format FIXME: for books Only
93
	# COinS format FIXME: for books Only
90
        my $coins_format;
94
        my $coins_format;
(-)a/opac/opac-detail.pl (-3 / +8 lines)
Lines 48-53 use Koha::DateUtils; Link Here
48
use C4::HTML5Media;
48
use C4::HTML5Media;
49
use C4::CourseReserves qw(GetItemCourseReservesInfo);
49
use C4::CourseReserves qw(GetItemCourseReservesInfo);
50
use Koha::RecordProcessor;
50
use Koha::RecordProcessor;
51
use Koha::AuthorisedValues;
51
use Koha::Virtualshelves;
52
use Koha::Virtualshelves;
52
use Koha::Ratings;
53
use Koha::Ratings;
53
use Koha::Reviews;
54
use Koha::Reviews;
Lines 543-551 if ( $itemtype ) { Link Here
543
    $dat->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
544
    $dat->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
544
    $dat->{'description'} = $itemtypes->{$itemtype}->{translated_description};
545
    $dat->{'description'} = $itemtypes->{$itemtype}->{translated_description};
545
}
546
}
546
my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
547
547
my $collections =  GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
548
my $shelflocations =
548
my $copynumbers = GetKohaAuthorisedValues('items.copynumber',$dat->{'frameworkcode'}, 'opac');
549
  { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
550
my $collections =
551
  { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.ccode' } ) };
552
my $copynumbers =
553
  { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.copynumber' } ) };
549
554
550
#coping with subscriptions
555
#coping with subscriptions
551
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
556
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
(-)a/reports/catalogue_stats.pl (-13 / +5 lines)
Lines 29-34 use C4::Reports; Link Here
29
use C4::Circulation;
29
use C4::Circulation;
30
use C4::Biblio qw/GetMarcSubfieldStructureFromKohaField/;
30
use C4::Biblio qw/GetMarcSubfieldStructureFromKohaField/;
31
31
32
use Koha::AuthorisedValues;
32
use Koha::DateUtils;
33
use Koha::DateUtils;
33
34
34
=head1 NAME
35
=head1 NAME
Lines 121-137 if ($do_it) { Link Here
121
122
122
    my $itemtypes = GetItemTypes( style => 'array' );
123
    my $itemtypes = GetItemTypes( style => 'array' );
123
124
124
    my $authvals = GetKohaAuthorisedValues("items.ccode");
125
    my @authvals = map { { code => $_->authorised_value, description => $_->lib } } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } );
125
    my @authvals;
126
    my @locations = map { { code => $_->authorised_value, description => $_->lib } } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } );
126
    foreach ( sort { $authvals->{$a} cmp $authvals->{$b} || $a cmp $b } keys %$authvals ) {
127
        push @authvals, { code => $_, description => $authvals->{$_} };
128
    }
129
130
    my $locations = GetKohaAuthorisedValues("items.location");
131
    my @locations;
132
    foreach ( sort keys %$locations ) {
133
        push @locations, { code => $_, description => "$_ - " . $locations->{$_} };
134
    }
135
127
136
    foreach my $kohafield (qw(items.notforloan items.materials)) {
128
    foreach my $kohafield (qw(items.notforloan items.materials)) {
137
        my $subfield_structure = GetMarcSubfieldStructureFromKohaField($kohafield);
129
        my $subfield_structure = GetMarcSubfieldStructureFromKohaField($kohafield);
Lines 322-328 sub calculate { Link Here
322
    } else {
314
    } else {
323
        $sth->execute();
315
        $sth->execute();
324
    }
316
    }
325
    my $rowauthvals = GetKohaAuthorisedValues($origline);
317
    my $rowauthvals = { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => $origline } ) };
326
    while ( my ($celvalue) = $sth->fetchrow ) {
318
    while ( my ($celvalue) = $sth->fetchrow ) {
327
        my %cell;
319
        my %cell;
328
        if (defined $celvalue and $celvalue ne '') {
320
        if (defined $celvalue and $celvalue ne '') {
Lines 385-391 sub calculate { Link Here
385
    } else {
377
    } else {
386
        $sth2->execute();
378
        $sth2->execute();
387
    }
379
    }
388
    my $colauthvals = GetKohaAuthorisedValues($origcolumn);
380
    my $colauthvals = { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => $origcolumn } ) };
389
    while ( my ($celvalue) = $sth2->fetchrow ) {
381
    while ( my ($celvalue) = $sth2->fetchrow ) {
390
        my %cell;
382
        my %cell;
391
        if (defined $celvalue and $celvalue ne '') {
383
        if (defined $celvalue and $celvalue ne '') {
(-)a/reports/issues_stats.pl (-2 / +4 lines)
Lines 31-36 use C4::Output; Link Here
31
use C4::Circulation;
31
use C4::Circulation;
32
use C4::Reports;
32
use C4::Reports;
33
use C4::Members;
33
use C4::Members;
34
35
use Koha::AuthorisedValues;
34
use Koha::DateUtils;
36
use Koha::DateUtils;
35
37
36
=head1 NAME
38
=head1 NAME
Lines 77-84 $template->param(do_it => $do_it, Link Here
77
our $itemtypes = GetItemTypes();
79
our $itemtypes = GetItemTypes();
78
our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
80
our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
79
81
80
our $ccodes    = GetKohaAuthorisedValues("items.ccode");
82
my $locations = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
81
our $locations = GetKohaAuthorisedValues("items.location");
83
my $ccodes = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
82
84
83
our $Bsort1 = GetAuthorisedValues("Bsort1");
85
our $Bsort1 = GetAuthorisedValues("Bsort1");
84
our $Bsort2 = GetAuthorisedValues("Bsort2");
86
our $Bsort2 = GetAuthorisedValues("Bsort2");
(-)a/reports/reserves_stats.pl (-7 / +5 lines)
Lines 30-35 use C4::Koha; Link Here
30
use C4::Output;
30
use C4::Output;
31
use C4::Reports;
31
use C4::Reports;
32
use C4::Members;
32
use C4::Members;
33
use Koha::AuthorisedValues;
33
use Koha::DateUtils;
34
use Koha::DateUtils;
34
use Koha::Libraries;
35
use Koha::Libraries;
35
use Koha::Patron::Categories;
36
use Koha::Patron::Categories;
Lines 83-91 $template->param(do_it => $do_it, Link Here
83
my $itemtypes = GetItemTypes();
84
my $itemtypes = GetItemTypes();
84
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
85
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
85
86
86
my $ccodes    = GetKohaAuthorisedValues("items.ccode");
87
my $locations = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
87
my $locations = GetKohaAuthorisedValues("items.location");
88
my $ccodes = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
88
my $authvalue = GetKohaAuthorisedValues("items.authvalue");
89
89
90
my $Bsort1 = GetAuthorisedValues("Bsort1");
90
my $Bsort1 = GetAuthorisedValues("Bsort1");
91
my $Bsort2 = GetAuthorisedValues("Bsort2");
91
my $Bsort2 = GetAuthorisedValues("Bsort2");
Lines 330-339 sub null_to_zzempty ($) { Link Here
330
}
330
}
331
sub display_value {
331
sub display_value {
332
    my ( $crit, $value ) = @_;
332
    my ( $crit, $value ) = @_;
333
    my $ccodes    = GetKohaAuthorisedValues("items.ccode");
333
    my $locations = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
334
    my $locations = GetKohaAuthorisedValues("items.location");
334
    my $ccodes = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
335
    my $itemtypes = GetItemTypes();
335
    my $itemtypes = GetItemTypes();
336
    my $authvalue = GetKohaAuthorisedValues("items.authvalue");
337
    my $Bsort1 = GetAuthorisedValues("Bsort1");
336
    my $Bsort1 = GetAuthorisedValues("Bsort1");
338
    my $Bsort2 = GetAuthorisedValues("Bsort2");
337
    my $Bsort2 = GetAuthorisedValues("Bsort2");
339
    my $display_value =
338
    my $display_value =
340
- 

Return to bug 17253