Bug 17253: Koha::AuthorisedValues - Remove GetKohaAuthorisedValues
This patch replaces the call to C4::Koha::GetKohaAuthorisedValues with Koha::AuthorisedValues->search_by_koha_field Test plan: AV descriptions should be displayed on the following pages: - XSLT view - location and ccode - Bibliographic detail, moredetail and OPAC pages - location, ccode, copynumber - returns - location - opac-basket - ccode, location - The 3 reports: catalogue_stats.pl, issues_stats.pl and reserves_stats.pl - location, ccode Signed-off-by: Claire Gravely <claire_gravely@hotmail.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
cd7b84f675
commit
baf78b2a33
28
C4/Koha.pm
28
C4/Koha.pm
|
|
@ -54,7 +54,6 @@ BEGIN {
|
|||
&getitemtypeimagelocation
|
||||
&GetAuthorisedValues
|
||||
&GetAuthorisedValueCategories
|
||||
&GetKohaAuthorisedValues
|
||||
&GetNormalizedUPC
|
||||
&GetNormalizedISBN
|
||||
&GetNormalizedEAN
|
||||
|
|
@ -965,33 +964,6 @@ sub GetAuthorisedValueCategories {
|
|||
return \@results;
|
||||
}
|
||||
|
||||
=head2 GetKohaAuthorisedValues
|
||||
|
||||
Takes $kohafield, $fwcode as parameters.
|
||||
|
||||
If $opac parameter is set to a true value, displays OPAC descriptions rather than normal ones when they exist.
|
||||
|
||||
Returns hashref of Code => description
|
||||
|
||||
Returns undef if no authorised value category is defined for the kohafield.
|
||||
|
||||
=cut
|
||||
|
||||
sub GetKohaAuthorisedValues {
|
||||
my ( $kohafield, $fwcode, $opac ) = @_;
|
||||
$fwcode = '' unless $fwcode;
|
||||
my %values;
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
my $avs = Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fwcode, kohafield => $kohafield } );
|
||||
return {} unless $avs->count;
|
||||
my $values;
|
||||
while ( my $av = $avs->next ) {
|
||||
$values->{ $av->authorised_value } = $opac ? $av->opac_description : $av->lib;
|
||||
}
|
||||
return $values;
|
||||
}
|
||||
|
||||
=head2 xml_escape
|
||||
|
||||
my $escaped_string = C4::Koha::xml_escape($string);
|
||||
|
|
|
|||
|
|
@ -1849,7 +1849,8 @@ sub searchResults {
|
|||
# FIXME - We build an authorised values hash here, using the default framework
|
||||
# though it is possible to have different authvals for different fws.
|
||||
|
||||
my $shelflocations =GetKohaAuthorisedValues('items.location','');
|
||||
my $shelflocations =
|
||||
{ map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
|
||||
|
||||
# get notforloan authorised value list (see $shelflocations FIXME)
|
||||
my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan', authorised_value => { not => undef } });
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ use C4::Koha;
|
|||
use C4::Biblio;
|
||||
use C4::Circulation;
|
||||
use C4::Reserves;
|
||||
use Koha::AuthorisedValues;
|
||||
use Koha::XSLT_Handler;
|
||||
use Koha::Libraries;
|
||||
|
||||
|
|
@ -272,8 +273,10 @@ sub buildKohaItemsNamespace {
|
|||
@items = grep { !$hi{$_->{itemnumber}} } @items;
|
||||
}
|
||||
|
||||
my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
|
||||
my $ccodes = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
|
||||
my $shelflocations =
|
||||
{ map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => GetFrameworkCode($biblionumber), kohafield => 'items.location' } ) };
|
||||
my $ccodes =
|
||||
{ map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => GetFrameworkCode($biblionumber), kohafield => 'items.ccode' } ) };
|
||||
|
||||
my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' });
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ use warnings;
|
|||
|
||||
use CGI qw ( -utf8 );
|
||||
use C4::Context;
|
||||
use C4::Koha; # GetKohaAuthorisedValues GetItemTypes
|
||||
use C4::Koha; # GetItemTypes
|
||||
use C4::Acquisition;
|
||||
use C4::Auth;
|
||||
use C4::Output;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ use C4::Items;
|
|||
use C4::Auth;
|
||||
use C4::Output;
|
||||
|
||||
use Koha::AuthorisedValues;
|
||||
use Koha::CsvProfiles;
|
||||
|
||||
my $query = new CGI;
|
||||
|
|
@ -75,8 +76,8 @@ foreach my $biblionumber ( @bibs ) {
|
|||
$hasauthors = 1;
|
||||
}
|
||||
|
||||
my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'});
|
||||
my $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'});
|
||||
my $shelflocations =
|
||||
{ map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
|
||||
|
||||
for my $itm (@items) {
|
||||
if ($itm->{'location'}){
|
||||
|
|
|
|||
|
|
@ -189,9 +189,12 @@ $dat->{'count'} = scalar @all_items + @hostitems;
|
|||
$dat->{'showncount'} = scalar @items + @hostitems;
|
||||
$dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items;
|
||||
|
||||
my $shelflocations = GetKohaAuthorisedValues('items.location', $fw);
|
||||
my $collections = GetKohaAuthorisedValues('items.ccode' , $fw);
|
||||
my $copynumbers = GetKohaAuthorisedValues('items.copynumber', $fw);
|
||||
my $shelflocations =
|
||||
{ map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) };
|
||||
my $collections =
|
||||
{ map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
|
||||
my $copynumbers =
|
||||
{ map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
|
||||
my (@itemloop, @otheritemloop, %itemfields);
|
||||
my $norequests = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -119,8 +119,10 @@ $data->{'count'}=$totalcount;
|
|||
$data->{'showncount'}=$showncount;
|
||||
$data->{'hiddencount'}=$hiddencount; # can be zero
|
||||
|
||||
my $ccodes= GetKohaAuthorisedValues('items.ccode',$fw);
|
||||
my $copynumbers = GetKohaAuthorisedValues('items.copynumber',$fw);
|
||||
my $ccodes =
|
||||
{ map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
|
||||
my $copynumbers =
|
||||
{ map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
|
||||
my $itemtypes = GetItemTypes;
|
||||
|
||||
$data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'translated_description'};
|
||||
|
|
|
|||
|
|
@ -551,7 +551,8 @@ $template->param( errmsgloop => \@errmsgloop );
|
|||
my $returned_counter = ( C4::Context->preference('numReturnedItemsToShow') ) ? C4::Context->preference('numReturnedItemsToShow') : 8;
|
||||
my $count = 0;
|
||||
my @riloop;
|
||||
my $shelflocations = GetKohaAuthorisedValues('items.location','');
|
||||
my $shelflocations =
|
||||
{ map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
|
||||
foreach ( sort { $a <=> $b } keys %returneditems ) {
|
||||
my %ri;
|
||||
if ( $count++ < $returned_counter ) {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ use C4::Auth;
|
|||
use C4::Output;
|
||||
use Koha::RecordProcessor;
|
||||
|
||||
use Koha::AuthorisedValues;
|
||||
|
||||
my $query = new CGI;
|
||||
|
||||
my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
|
||||
|
|
@ -83,8 +85,10 @@ foreach my $biblionumber ( @bibs ) {
|
|||
if($dat->{'author'} || @$marcauthorsarray) {
|
||||
$hasauthors = 1;
|
||||
}
|
||||
my $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
|
||||
my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
|
||||
my $collections =
|
||||
{ map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.ccode' } ) };
|
||||
my $shelflocations =
|
||||
{ map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
|
||||
|
||||
# COinS format FIXME: for books Only
|
||||
my $coins_format;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ use Koha::DateUtils;
|
|||
use C4::HTML5Media;
|
||||
use C4::CourseReserves qw(GetItemCourseReservesInfo);
|
||||
use Koha::RecordProcessor;
|
||||
use Koha::AuthorisedValues;
|
||||
use Koha::Virtualshelves;
|
||||
use Koha::Ratings;
|
||||
use Koha::Reviews;
|
||||
|
|
@ -543,9 +544,13 @@ if ( $itemtype ) {
|
|||
$dat->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
|
||||
$dat->{'description'} = $itemtypes->{$itemtype}->{translated_description};
|
||||
}
|
||||
my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
|
||||
my $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
|
||||
my $copynumbers = GetKohaAuthorisedValues('items.copynumber',$dat->{'frameworkcode'}, 'opac');
|
||||
|
||||
my $shelflocations =
|
||||
{ map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
|
||||
my $collections =
|
||||
{ map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.ccode' } ) };
|
||||
my $copynumbers =
|
||||
{ map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.copynumber' } ) };
|
||||
|
||||
#coping with subscriptions
|
||||
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ use C4::Reports;
|
|||
use C4::Circulation;
|
||||
use C4::Biblio qw/GetMarcSubfieldStructureFromKohaField/;
|
||||
|
||||
use Koha::AuthorisedValues;
|
||||
use Koha::DateUtils;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -121,17 +122,8 @@ if ($do_it) {
|
|||
|
||||
my $itemtypes = GetItemTypes( style => 'array' );
|
||||
|
||||
my $authvals = GetKohaAuthorisedValues("items.ccode");
|
||||
my @authvals;
|
||||
foreach ( sort { $authvals->{$a} cmp $authvals->{$b} || $a cmp $b } keys %$authvals ) {
|
||||
push @authvals, { code => $_, description => $authvals->{$_} };
|
||||
}
|
||||
|
||||
my $locations = GetKohaAuthorisedValues("items.location");
|
||||
my @locations;
|
||||
foreach ( sort keys %$locations ) {
|
||||
push @locations, { code => $_, description => "$_ - " . $locations->{$_} };
|
||||
}
|
||||
my @authvals = map { { code => $_->authorised_value, description => $_->lib } } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } );
|
||||
my @locations = map { { code => $_->authorised_value, description => $_->lib } } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } );
|
||||
|
||||
foreach my $kohafield (qw(items.notforloan items.materials)) {
|
||||
my $subfield_structure = GetMarcSubfieldStructureFromKohaField($kohafield);
|
||||
|
|
@ -322,7 +314,7 @@ sub calculate {
|
|||
} else {
|
||||
$sth->execute();
|
||||
}
|
||||
my $rowauthvals = GetKohaAuthorisedValues($origline);
|
||||
my $rowauthvals = { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => $origline } ) };
|
||||
while ( my ($celvalue) = $sth->fetchrow ) {
|
||||
my %cell;
|
||||
if (defined $celvalue and $celvalue ne '') {
|
||||
|
|
@ -385,7 +377,7 @@ sub calculate {
|
|||
} else {
|
||||
$sth2->execute();
|
||||
}
|
||||
my $colauthvals = GetKohaAuthorisedValues($origcolumn);
|
||||
my $colauthvals = { map { $_->authorised_value => $_->lib } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => $origcolumn } ) };
|
||||
while ( my ($celvalue) = $sth2->fetchrow ) {
|
||||
my %cell;
|
||||
if (defined $celvalue and $celvalue ne '') {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ use C4::Output;
|
|||
use C4::Circulation;
|
||||
use C4::Reports;
|
||||
use C4::Members;
|
||||
|
||||
use Koha::AuthorisedValues;
|
||||
use Koha::DateUtils;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -77,8 +79,8 @@ $template->param(do_it => $do_it,
|
|||
our $itemtypes = GetItemTypes();
|
||||
our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
|
||||
|
||||
our $ccodes = GetKohaAuthorisedValues("items.ccode");
|
||||
our $locations = GetKohaAuthorisedValues("items.location");
|
||||
my $locations = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
|
||||
my $ccodes = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
|
||||
|
||||
our $Bsort1 = GetAuthorisedValues("Bsort1");
|
||||
our $Bsort2 = GetAuthorisedValues("Bsort2");
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ use C4::Koha;
|
|||
use C4::Output;
|
||||
use C4::Reports;
|
||||
use C4::Members;
|
||||
use Koha::AuthorisedValues;
|
||||
use Koha::DateUtils;
|
||||
use Koha::Libraries;
|
||||
use Koha::Patron::Categories;
|
||||
|
|
@ -83,9 +84,8 @@ $template->param(do_it => $do_it,
|
|||
my $itemtypes = GetItemTypes();
|
||||
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
|
||||
|
||||
my $ccodes = GetKohaAuthorisedValues("items.ccode");
|
||||
my $locations = GetKohaAuthorisedValues("items.location");
|
||||
my $authvalue = GetKohaAuthorisedValues("items.authvalue");
|
||||
my $locations = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
|
||||
my $ccodes = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
|
||||
|
||||
my $Bsort1 = GetAuthorisedValues("Bsort1");
|
||||
my $Bsort2 = GetAuthorisedValues("Bsort2");
|
||||
|
|
@ -330,10 +330,9 @@ sub null_to_zzempty ($) {
|
|||
}
|
||||
sub display_value {
|
||||
my ( $crit, $value ) = @_;
|
||||
my $ccodes = GetKohaAuthorisedValues("items.ccode");
|
||||
my $locations = GetKohaAuthorisedValues("items.location");
|
||||
my $locations = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
|
||||
my $ccodes = { map { ( $_->authorised_value => $_->lib ) } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
|
||||
my $itemtypes = GetItemTypes();
|
||||
my $authvalue = GetKohaAuthorisedValues("items.authvalue");
|
||||
my $Bsort1 = GetAuthorisedValues("Bsort1");
|
||||
my $Bsort2 = GetAuthorisedValues("Bsort2");
|
||||
my $display_value =
|
||||
|
|
|
|||
Loading…
Reference in New Issue