# along with Koha; if not, see <http://www.gnu.org/licenses>.
-use strict;
-use warnings;
+use Modern::Perl;
use CGI qw ( -utf8 );
+use HTML::Entities;
use C4::Acquisition qw( GetHistory );
use C4::Auth;
use C4::Koha;
use C4::Biblio;
use C4::Items;
use C4::Circulation;
-use C4::Branch;
use C4::Reserves;
use C4::Members; # to use GetMember
use C4::Serials;
use C4::HTML5Media;
use C4::CourseReserves qw(GetItemCourseReservesInfo);
use C4::Acquisition qw(GetOrdersByBiblionumber);
+use Koha::AuthorisedValues;
use Koha::Virtualshelves;
my $query = CGI->new();
);
my $biblionumber = $query->param('biblionumber');
+$biblionumber = HTML::Entities::encode($biblionumber);
my $record = GetMarcBiblio($biblionumber);
if ( not defined $record ) {
my $marcflavour = C4::Context->preference("marcflavour");
# XSLT processing of some stuff
-if (C4::Context->preference("XSLTDetailsDisplay") ) {
- $template->param('XSLTDetailsDisplay' =>'1',
- 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "XSLTDetailsDisplay") );
+my $xslfile = C4::Context->preference('XSLTDetailsDisplay');
+my $lang = $xslfile ? C4::Languages::getlanguage() : undef;
+my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
+
+if ( $xslfile ) {
+ $template->param(
+ XSLTDetailsDisplay => '1',
+ XSLTBloc => XSLTParse4Display(
+ $biblionumber, $record, "XSLTDetailsDisplay",
+ 1, undef, $sysxml, $xslfile, $lang
+ )
+ );
}
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
my $subtitle = GetRecordValue('subtitle', $record, $fw);
# Get Branches, Itemtypes and Locations
-my $branches = GetBranches();
my $itemtypes = GetItemTypes();
my $dbh = C4::Context->dbh;
$cell{missinglist} = $subscription->{missinglist};
$cell{librariannote} = $subscription->{librariannote};
$cell{branchcode} = $subscription->{branchcode};
- $cell{branchname} = GetBranchName($subscription->{branchcode});
$cell{hasalert} = $subscription->{hasalert};
$cell{callnumber} = $subscription->{callnumber};
$cell{closed} = $subscription->{closed};
$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;
-my $authvalcode_items_itemlost = GetAuthValCode('items.itemlost',$fw);
-my $authvalcode_items_damaged = GetAuthValCode('items.damaged', $fw);
+
+my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => { not => undef } });
+if ( $mss->count ) {
+ $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) );
+}
+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => { not => undef } });
+if ( $mss->count ) {
+ $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) );
+}
+
+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => { not => undef } });
+my %materials_map;
+if ($mss->count) {
+ my $materials_authvals = GetAuthorisedValues($mss->next->authorised_value);
+ if ($materials_authvals) {
+ foreach my $value (@$materials_authvals) {
+ $materials_map{$value->{authorised_value}} = $value->{lib};
+ }
+ }
+}
my $analytics_flag;
my $materials_flag; # set this if the items have anything in the materials field
: '';
$item->{datedue} = format_sqldatetime($item->{datedue});
- # item damaged, lost, withdrawn loops
- $item->{itemlostloop} = GetAuthorisedValues($authvalcode_items_itemlost, $item->{itemlost}) if $authvalcode_items_itemlost;
- if ($item->{damaged}) {
- $item->{itemdamagedloop} = GetAuthorisedValues($authvalcode_items_damaged, $item->{damaged}) if $authvalcode_items_damaged;
- }
+
#get shelf location and collection code description if they are authorised value.
# same thing for copy number
my $shelfcode = $item->{'location'};
$item->{ReservedForBorrowernumber} = $reservedfor;
$item->{ReservedForSurname} = $ItemBorrowerReserveInfo->{'surname'};
$item->{ReservedForFirstname} = $ItemBorrowerReserveInfo->{'firstname'};
- $item->{ExpectedAtLibrary} = $branches->{$expectedAt}{branchname};
+ $item->{ExpectedAtLibrary} = $expectedAt;
$item->{Reservedcardnumber} = $ItemBorrowerReserveInfo->{'cardnumber'};
# Check waiting status
$item->{waitingdate} = $wait;
my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber});
if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) {
$item->{transfertwhen} = $transfertwhen;
- $item->{transfertfrom} = $branches->{$transfertfrom}{branchname};
- $item->{transfertto} = $branches->{$transfertto}{branchname};
+ $item->{transfertfrom} = $transfertfrom;
+ $item->{transfertto} = $transfertto;
$item->{nocancel} = 1;
}
}
if (defined($item->{'materials'}) && $item->{'materials'} =~ /\S/){
- $materials_flag = 1;
+ $materials_flag = 1;
+ if (defined $materials_map{ $item->{materials} }) {
+ $item->{materials} = $materials_map{ $item->{materials} };
+ }
}
if ( C4::Context->preference('UseCourseReserves') ) {
subscriptions => \@subs,
subscriptionsnumber => $subscriptionsnumber,
subscriptiontitle => $dat->{title},
- searchid => $query->param('searchid'),
+ searchid => scalar $query->param('searchid'),
);
# $debug and $template->param(debug_display => 1);