use C4::Koha qw(
GetAuthorisedValueByCode
GetAuthValCode
- GetKohaAuthorisedValueLib
);
use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units);
use C4::RotatingCollections qw(GetCollectionItemBranches);
use DateTime::Format::MySQL;
use Data::Dumper; # used as part of logging item record changes, not just for
# debugging; so please don't remove this
+
+use Koha::AuthorisedValues;
use Koha::DateUtils qw/dt_from_string/;
use Koha::Database;
# get notforloan complete status if applicable
if ( my $code = C4::Koha::GetAuthValCode( 'items.notforloan', $data->{frameworkcode} ) ) {
- $data->{notforloanvalue} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{itemnotforloan} );
- $data->{notforloanvalueopac} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{itemnotforloan}, 1 );
+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{itemnotforloan} });
+ $av = $av->count ? $av->next : undef;
+ $data->{notforloanvalue} = $av ? $av->lib : '';
+ $data->{notforloanvalueopac} = $av ? $av->opac_description : '';
}
# get restricted status and description if applicable
if ( my $code = C4::Koha::GetAuthValCode( 'items.restricted', $data->{frameworkcode} ) ) {
- $data->{restrictedopac} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{restricted}, 1 );
- $data->{restricted} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{restricted} );
+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{restricted} });
+ $av = $av->count ? $av->next : undef;
+ $data->{restricted} = $av ? $av->lib : '';
+ $data->{restrictedopac} = $av ? $av->opac_description : '';
}
# my stack procedures
if ( my $code = C4::Koha::GetAuthValCode( 'items.stack', $data->{frameworkcode} ) ) {
- $data->{stack} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{stack} );
+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $data->{stack} });
+ $data->{stack} = $av->count ? $av->next->lib : '';
}
# Find the last 3 people who borrowed this item.
$sth->execute($biblionumber);
while ( my $data = $sth->fetchrow_hashref ) {
- $data->{location_intranet} = GetKohaAuthorisedValueLib('LOC', $data->{location});
- $data->{location_opac}= GetKohaAuthorisedValueLib('LOC', $data->{location}, 1);
+ my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $data->{location} });
+ $av = $av->count ? $av->next : undef;
+ $data->{location_intranet} = $av ? $av->lib : '';
+ $data->{location_opac} = $av ? $av->opac_description : '';
push @results, $data;
}
return @results;
&GetKohaAuthorisedValues
&GetKohaAuthorisedValuesFromField
&GetKohaAuthorisedValuesMapping
- &GetKohaAuthorisedValueLib
&GetAuthorisedValueByCode
&GetAuthValCode
&GetNormalizedUPC
return $str;
}
-=head2 GetKohaAuthorisedValueLib
-
-Takes $category, $authorised_value as parameters.
-
-If $opac parameter is set to a true value, displays OPAC descriptions rather than normal ones when they exist.
-
-Returns authorised value description
-
-=cut
-
-sub GetKohaAuthorisedValueLib {
- my ($category,$authorised_value,$opac) = @_;
- my $value;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("select lib, lib_opac from authorised_values where category=? and authorised_value=?");
- $sth->execute($category,$authorised_value);
- my $data = $sth->fetchrow_hashref;
- $value = ($opac && $$data{'lib_opac'}) ? $$data{'lib_opac'} : $$data{'lib'};
- return $value;
-}
-
=head2 display_marc_indicators
my $display_form = C4::Koha::display_marc_indicators($field);
use C4::Reserves; # GetReserveStatus
use C4::Debug;
use C4::Charset;
+use Koha::AuthorisedValues;
+use Koha::Libraries;
use YAML;
use URI::Escape;
use Business::ISBN;
# also, if it's a location code, use the name instead of the code
if ( $link_value =~ /location/ ) {
- $facet_label_value =
- GetKohaAuthorisedValueLib( 'LOC',
- $one_facet, $opac );
+ # TODO Retrieve all authorised values at once, instead of 1 query per entry
+ my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $one_facet });
+ $facet_label_value = $av->count ? $av->next->opac_description : '';
}
# but we're down with the whole label being in the link's title.
foreach (@itemnumbers) {
my $item = GetItem($_);
if(my $code = GetAuthValCode("items.notforloan", $fw)) {
- $item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan});
+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{notforloan} });
+ $item->{notforloan} = $av->count ? $av->next->lib : '';
}
if(my $code = GetAuthValCode("items.restricted", $fw)) {
- $item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted});
+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{restricted} });
+ $item->{restricted} = $av->count ? $av->next->lib : '';
}
if(my $code = GetAuthValCode("items.location", $fw)) {
- $item->{location} = GetKohaAuthorisedValueLib($code, $item->{location});
+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{location} });
+ $item->{location} = $av->count ? $av->next->lib : '';
}
if(my $code = GetAuthValCode("items.ccode", $fw)) {
- $item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode});
+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{collection} });
+ $item->{collection} = $av->count ? $av->next->lib : '';
}
if(my $code = GetAuthValCode("items.materials", $fw)) {
- $item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials});
+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_value => $item->{materials} });
+ $item->{materials} = $av->count ? $av->next->lib : '';
}
my $itemtype = getitemtypeinfo($item->{itype});
$item->{itemtype} = $itemtype->{description};
use C4::Output;
use Koha::Libraries;
+use Koha::AuthorisedValues;
+
my $cgi = new CGI;
my ( $status, $cookie, $sessionID ) = C4::Auth::check_api_auth( $cgi, { acquisition => 'order_receive' } );
}
if(my $code = GetAuthValCode("items.notforloan", $fw)) {
- $item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan});
+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{notforloan} });
+ $item->{notforloan} = $av->count ? $av->next->lib : '';
}
if(my $code = GetAuthValCode("items.restricted", $fw)) {
- $item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted});
+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{restricted} });
+ $item->{restricted} = $av->count ? $av->next->lib : '';
}
if(my $code = GetAuthValCode("items.location", $fw)) {
- $item->{location} = GetKohaAuthorisedValueLib($code, $item->{location});
+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{location} });
+ $item->{location} = $av->count ? $av->next->lib : '';
}
if(my $code = GetAuthValCode("items.ccode", $fw)) {
- $item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode});
+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{collection} });
+ $item->{collection} = $av->count ? $av->next->lib : '';
}
if(my $code = GetAuthValCode("items.materials", $fw)) {
- $item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials});
+ my $av = Koha::AuthorisedValues->search({ category => $code, authorised_values => $item->{materials} });
+ $item->{materials} = $av->count ? $av->next->lib : '';
}
my $itemtype = getitemtypeinfo($item->{itype});
use C4::Koha;
use C4::Members;
+use Koha::AuthorisedValues;
+
###############################################
# Getting state
$item{'itemtype'} = $iteminformation->{'itemtype'};
$item{'ccode'} = $iteminformation->{'ccode'};
$item{'itemcallnumber'} = $iteminformation->{'itemcallnumber'};
- $item{'location'} = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'});
+ my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $iteminformation->{location} });
+ $item{'location'} = $av->count ? $av->next->lib : '';
# }
$item{counter} = 0;
$item{barcode} = $barcode;
$item{'itemtype'} = $iteminformation->{'itemtype'};
$item{'ccode'} = $iteminformation->{'ccode'};
$item{'itemcallnumber'} = $iteminformation->{'itemcallnumber'};
- $item{'location'} = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'});
+ my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $iteminformation->{location} });
+ $item{'location'} = $av->count ? $av->next->lib : '';
push( @trsfitemloop, \%item );
}
use C4::Context;
use CGI::Session;
use C4::Members::Attributes qw(GetBorrowerAttributes);
+use Koha::AuthorisedValues;
use Koha::Patron;
use Koha::Patron::Debarments qw(GetDebarments);
use Koha::DateUtils;
my $materials = $iteminfo->{'materials'};
my $avcode = GetAuthValCode('items.materials');
if ($avcode) {
- $materials = GetKohaAuthorisedValueLib($avcode, $materials);
+ my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials });
+ $materials = $av->count ? $av->next->lib : '';
}
$template_params->{additional_materials} = $materials;
$template_params->{itemhomebranch} = $iteminfo->{'homebranch'};
use C4::Members::Messaging;
use C4::Koha; # FIXME : is it still useful ?
use C4::RotatingCollections;
+use Koha::AuthorisedValues;
use Koha::DateUtils;
use Koha::Calendar;
my $materials = $biblio->{'materials'};
my $avcode = GetAuthValCode('items.materials');
if ($avcode) {
- $materials = GetKohaAuthorisedValueLib($avcode, $materials);
+ my $av = Koha::AuthorisedValues->search({ category => $avcode, authorised_value => $materials });
+ $materials = $av->count ? $av->next->lib : '';
}
$template->param(
use C4::Suggestions;
use C4::Koha;
use C4::Scrubber;
+
+use Koha::AuthorisedValues;
use Koha::Libraries;
use Koha::DateUtils qw( dt_from_string );
$suggestion->{'showcheckbox'} = 0;
}
if($suggestion->{'patronreason'}){
- $suggestion->{'patronreason'} = GetKohaAuthorisedValueLib("OPAC_SUG",$suggestion->{'patronreason'},1);
+ my $av = Koha::AuthorisedValues->search({ category => 'OPAC_SUG', authorised_value => $suggestion->{patronreason} });
+ $suggestion->{'patronreason'} = $av->count ? $av->next->opac_description : '';
}
}
use C4::Output;
use C4::Context;
use C4::Search qw/enabled_staff_search_views/;
-use Koha::DateUtils;
+use Koha::AuthorisedValues;
+use Koha::DateUtils;
use Koha::Acquisition::Bookseller;
use Date::Calc qw/Today Day_of_Year Week_of_Year Add_Delta_Days/;
$subs->{$date} = output_pref( { str => $subs->{$date}, dateonly => 1 } )
if $subs->{$date};
}
-$subs->{location} = GetKohaAuthorisedValueLib("LOC",$subs->{location});
+my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $subs->{location} });
+$subs->{location} = $av->count ? $av->next->lib : '';
$subs->{abouttoexpire} = abouttoexpire($subs->{subscriptionid});
$template->param(%{ $subs });
$template->param(biblionumber_for_new_subscription => $subs->{bibnum});