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

(-)a/C4/Koha.pm (-28 lines)
Lines 56-62 BEGIN { Link Here
56
		&getitemtypeimagelocation
56
		&getitemtypeimagelocation
57
		&GetAuthorisedValues
57
		&GetAuthorisedValues
58
		&GetAuthorisedValueCategories
58
		&GetAuthorisedValueCategories
59
		&GetKohaAuthorisedValues
60
		&GetNormalizedUPC
59
		&GetNormalizedUPC
61
		&GetNormalizedISBN
60
		&GetNormalizedISBN
62
		&GetNormalizedEAN
61
		&GetNormalizedEAN
Lines 1040-1072 sub GetAuthorisedValueCategories { Link Here
1040
    return \@results;
1039
    return \@results;
1041
}
1040
}
1042
1041
1043
=head2 GetKohaAuthorisedValues
1044
1045
Takes $kohafield, $fwcode as parameters.
1046
1047
If $opac parameter is set to a true value, displays OPAC descriptions rather than normal ones when they exist.
1048
1049
Returns hashref of Code => description
1050
1051
Returns undef if no authorised value category is defined for the kohafield.
1052
1053
=cut
1054
1055
sub GetKohaAuthorisedValues {
1056
    my ( $kohafield, $fwcode, $opac ) = @_;
1057
    $fwcode = '' unless $fwcode;
1058
    my %values;
1059
    my $dbh = C4::Context->dbh;
1060
1061
    my $avs = Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fwcode, kohafield => $kohafield } );
1062
    return {} unless $avs->count;
1063
    my $values;
1064
    while ( my $av = $avs->next ) {
1065
        $values->{ $av->authorised_value } = $opac ? $av->opac_description : $av->lib;
1066
    }
1067
    return $values;
1068
}
1069
1070
=head2 xml_escape
1042
=head2 xml_escape
1071
1043
1072
  my $escaped_string = C4::Koha::xml_escape($string);
1044
  my $escaped_string = C4::Koha::xml_escape($string);
(-)a/C4/Search.pm (-1 / +2 lines)
Lines 1851-1857 sub searchResults { Link Here
1851
# FIXME - We build an authorised values hash here, using the default framework
1851
# FIXME - We build an authorised values hash here, using the default framework
1852
# though it is possible to have different authvals for different fws.
1852
# though it is possible to have different authvals for different fws.
1853
1853
1854
    my $shelflocations =GetKohaAuthorisedValues('items.location','');
1854
    my $shelflocations =
1855
      { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
1855
1856
1856
    # get notforloan authorised value list (see $shelflocations  FIXME)
1857
    # get notforloan authorised value list (see $shelflocations  FIXME)
1857
    my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan' });
1858
    my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan' });
(-)a/C4/XSLT.pm (-2 / +5 lines)
Lines 31-36 use C4::Koha; Link Here
31
use C4::Biblio;
31
use C4::Biblio;
32
use C4::Circulation;
32
use C4::Circulation;
33
use C4::Reserves;
33
use C4::Reserves;
34
use Koha::AuthorisedValues;
34
use Koha::XSLT_Handler;
35
use Koha::XSLT_Handler;
35
use Koha::Libraries;
36
use Koha::Libraries;
36
37
Lines 274-281 sub buildKohaItemsNamespace { Link Here
274
        @items = grep { !$hi{$_->{itemnumber}} } @items;
275
        @items = grep { !$hi{$_->{itemnumber}} } @items;
275
    }
276
    }
276
277
277
    my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
278
    my $shelflocations =
278
    my $ccodes         = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
279
      { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => GetFrameworkCode($biblionumber), kohafield => 'items.location' } ) };
280
    my $ccodes =
281
      { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => GetFrameworkCode($biblionumber), kohafield => 'items.ccode' } ) };
279
282
280
    my $branches = GetBranches();
283
    my $branches = GetBranches();
281
    my $itemtypes = GetItemTypes();
284
    my $itemtypes = GetItemTypes();
(-)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 192-200 $dat->{'count'} = scalar @all_items + @hostitems; Link Here
192
$dat->{'showncount'} = scalar @items + @hostitems;
192
$dat->{'showncount'} = scalar @items + @hostitems;
193
$dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items;
193
$dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items;
194
194
195
my $shelflocations = GetKohaAuthorisedValues('items.location', $fw);
195
my $shelflocations =
196
my $collections    = GetKohaAuthorisedValues('items.ccode'   , $fw);
196
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) };
197
my $copynumbers    = GetKohaAuthorisedValues('items.copynumber', $fw);
197
my $collections =
198
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
199
my $copynumbers =
200
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
198
my (@itemloop, @otheritemloop, %itemfields);
201
my (@itemloop, @otheritemloop, %itemfields);
199
my $norequests = 1;
202
my $norequests = 1;
200
203
(-)a/catalogue/moredetail.pl (-2 / +4 lines)
Lines 120-127 $data->{'count'}=$totalcount; Link Here
120
$data->{'showncount'}=$showncount;
120
$data->{'showncount'}=$showncount;
121
$data->{'hiddencount'}=$hiddencount;  # can be zero
121
$data->{'hiddencount'}=$hiddencount;  # can be zero
122
122
123
my $ccodes= GetKohaAuthorisedValues('items.ccode',$fw);
123
my $ccodes =
124
my $copynumbers = GetKohaAuthorisedValues('items.copynumber',$fw);
124
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
125
my $copynumbers =
126
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
125
my $itemtypes = GetItemTypes;
127
my $itemtypes = GetItemTypes;
126
128
127
$data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'translated_description'};
129
$data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'translated_description'};
(-)a/circ/returns.pl (-1 / +2 lines)
Lines 556-562 $template->param( errmsgloop => \@errmsgloop ); Link Here
556
my $returned_counter = ( C4::Context->preference('numReturnedItemsToShow') ) ? C4::Context->preference('numReturnedItemsToShow') : 8;
556
my $returned_counter = ( C4::Context->preference('numReturnedItemsToShow') ) ? C4::Context->preference('numReturnedItemsToShow') : 8;
557
my $count = 0;
557
my $count = 0;
558
my @riloop;
558
my @riloop;
559
my $shelflocations = GetKohaAuthorisedValues('items.location','');
559
my $shelflocations =
560
  { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
560
foreach ( sort { $a <=> $b } keys %returneditems ) {
561
foreach ( sort { $a <=> $b } keys %returneditems ) {
561
    my %ri;
562
    my %ri;
562
    if ( $count++ < $returned_counter ) {
563
    if ( $count++ < $returned_counter ) {
(-)a/opac/opac-basket.pl (-2 / +6 lines)
Lines 27-32 use C4::Circulation; Link Here
27
use C4::Auth;
27
use C4::Auth;
28
use C4::Output;
28
use C4::Output;
29
29
30
use Koha::AuthorisedValues;
31
30
my $query = new CGI;
32
my $query = new CGI;
31
33
32
my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
34
my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
Lines 77-84 foreach my $biblionumber ( @bibs ) { Link Here
77
    if($dat->{'author'} || @$marcauthorsarray) {
79
    if($dat->{'author'} || @$marcauthorsarray) {
78
      $hasauthors = 1;
80
      $hasauthors = 1;
79
    }
81
    }
80
    my $collections =  GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
82
    my $collections =
81
    my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
83
      { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.ccode' } ) };
84
    my $shelflocations =
85
      { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
82
86
83
	# COinS format FIXME: for books Only
87
	# COinS format FIXME: for books Only
84
        my $coins_format;
88
        my $coins_format;
(-)a/opac/opac-detail.pl (-3 / +8 lines)
Lines 51-56 use Koha::DateUtils; Link Here
51
use C4::HTML5Media;
51
use C4::HTML5Media;
52
use C4::CourseReserves qw(GetItemCourseReservesInfo);
52
use C4::CourseReserves qw(GetItemCourseReservesInfo);
53
53
54
use Koha::AuthorisedValues;
54
use Koha::Virtualshelves;
55
use Koha::Virtualshelves;
55
56
56
BEGIN {
57
BEGIN {
Lines 532-540 if ( $itemtype ) { Link Here
532
    $dat->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
533
    $dat->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
533
    $dat->{'description'} = $itemtypes->{$itemtype}->{translated_description};
534
    $dat->{'description'} = $itemtypes->{$itemtype}->{translated_description};
534
}
535
}
535
my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
536
536
my $collections =  GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
537
my $shelflocations =
537
my $copynumbers = GetKohaAuthorisedValues('items.copynumber',$dat->{'frameworkcode'}, 'opac');
538
  { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
539
my $collections =
540
  { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.ccode' } ) };
541
my $copynumbers =
542
  { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.copynumber' } ) };
538
543
539
#coping with subscriptions
544
#coping with subscriptions
540
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
545
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
(-)a/reports/catalogue_stats.pl (-13 / +5 lines)
Lines 30-35 use C4::Reports; Link Here
30
use C4::Circulation;
30
use C4::Circulation;
31
use C4::Biblio qw/GetMarcSubfieldStructureFromKohaField/;
31
use C4::Biblio qw/GetMarcSubfieldStructureFromKohaField/;
32
32
33
use Koha::AuthorisedValues;
33
use Koha::DateUtils;
34
use Koha::DateUtils;
34
35
35
=head1 NAME
36
=head1 NAME
Lines 122-138 if ($do_it) { Link Here
122
123
123
    my $itemtypes = GetItemTypes( style => 'array' );
124
    my $itemtypes = GetItemTypes( style => 'array' );
124
125
125
    my $authvals = GetKohaAuthorisedValues("items.ccode");
126
    my @authvals = map { { code => $_->authorised_value, description => $_->lib } } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } );
126
    my @authvals;
127
    my @locations = map { { code => $_->authorised_value, description => $_->lib } } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } );
127
    foreach ( sort { $authvals->{$a} cmp $authvals->{$b} || $a cmp $b } keys %$authvals ) {
128
        push @authvals, { code => $_, description => $authvals->{$_} };
129
    }
130
131
    my $locations = GetKohaAuthorisedValues("items.location");
132
    my @locations;
133
    foreach ( sort keys %$locations ) {
134
        push @locations, { code => $_, description => "$_ - " . $locations->{$_} };
135
    }
136
128
137
    foreach my $kohafield (qw(items.notforloan items.materials)) {
129
    foreach my $kohafield (qw(items.notforloan items.materials)) {
138
        my $subfield_structure = GetMarcSubfieldStructureFromKohaField($kohafield);
130
        my $subfield_structure = GetMarcSubfieldStructureFromKohaField($kohafield);
Lines 324-330 sub calculate { Link Here
324
    } else {
316
    } else {
325
        $sth->execute();
317
        $sth->execute();
326
    }
318
    }
327
    my $rowauthvals = GetKohaAuthorisedValues($origline);
319
    my $rowauthvals = { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => $origline } ) };
328
    while ( my ($celvalue) = $sth->fetchrow ) {
320
    while ( my ($celvalue) = $sth->fetchrow ) {
329
        my %cell;
321
        my %cell;
330
        if (defined $celvalue and $celvalue ne '') {
322
        if (defined $celvalue and $celvalue ne '') {
Lines 387-393 sub calculate { Link Here
387
    } else {
379
    } else {
388
        $sth2->execute();
380
        $sth2->execute();
389
    }
381
    }
390
    my $colauthvals = GetKohaAuthorisedValues($origcolumn);
382
    my $colauthvals = { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => $origcolumn } ) };
391
    while ( my ($celvalue) = $sth2->fetchrow ) {
383
    while ( my ($celvalue) = $sth2->fetchrow ) {
392
        my %cell;
384
        my %cell;
393
        if (defined $celvalue and $celvalue ne '') {
385
        if (defined $celvalue and $celvalue ne '') {
(-)a/reports/issues_stats.pl (-2 / +4 lines)
Lines 32-37 use C4::Output; Link Here
32
use C4::Circulation;
32
use C4::Circulation;
33
use C4::Reports;
33
use C4::Reports;
34
use C4::Members;
34
use C4::Members;
35
36
use Koha::AuthorisedValues;
35
use Koha::DateUtils;
37
use Koha::DateUtils;
36
38
37
=head1 NAME
39
=head1 NAME
Lines 78-85 $template->param(do_it => $do_it, Link Here
78
our $itemtypes = GetItemTypes();
80
our $itemtypes = GetItemTypes();
79
our $categoryloop = GetBorrowercategoryList;
81
our $categoryloop = GetBorrowercategoryList;
80
82
81
our $ccodes    = GetKohaAuthorisedValues("items.ccode");
83
my $locations = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
82
our $locations = GetKohaAuthorisedValues("items.location");
84
my $ccodes = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
83
85
84
our $Bsort1 = GetAuthorisedValues("Bsort1");
86
our $Bsort1 = GetAuthorisedValues("Bsort1");
85
our $Bsort2 = GetAuthorisedValues("Bsort2");
87
our $Bsort2 = GetAuthorisedValues("Bsort2");
(-)a/reports/reserves_stats.pl (-4 / +3 lines)
Lines 32-37 use C4::Output; Link Here
32
use C4::Reports;
32
use C4::Reports;
33
use C4::Members;
33
use C4::Members;
34
use C4::Category;
34
use C4::Category;
35
use Koha::AuthorisedValues;
35
use Koha::DateUtils;
36
use Koha::DateUtils;
36
use List::MoreUtils qw/any/;
37
use List::MoreUtils qw/any/;
37
use YAML;
38
use YAML;
Lines 83-91 $template->param(do_it => $do_it, Link Here
83
my $itemtypes = GetItemTypes();
84
my $itemtypes = GetItemTypes();
84
my $categoryloop = GetBorrowercategoryList;
85
my $categoryloop = GetBorrowercategoryList;
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");
92
- 

Return to bug 17253