X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=catalogue%2Fdetail.pl;h=a31a0c5fac02b5ab9fcb88abcec04079fecc8aab;hb=0a40e0c60ff2ac405960cfd34033dd3d5896ac08;hp=e971ce7928063d76cbbd454f3101e5af1f8b7a77;hpb=6cb68b471dc1bf7658dfc1aa73aa23ce685342a8;p=koha.git diff --git a/catalogue/detail.pl b/catalogue/detail.pl index e971ce7928..a31a0c5fac 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -16,10 +16,10 @@ # along with Koha; if not, see . -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; @@ -28,7 +28,6 @@ use C4::Output; use C4::Biblio; use C4::Items; use C4::Circulation; -use C4::Branch; use C4::Reserves; use C4::Members; # to use GetMember use C4::Serials; @@ -42,6 +41,8 @@ use Koha::DateUtils; use C4::HTML5Media; use C4::CourseReserves qw(GetItemCourseReservesInfo); use C4::Acquisition qw(GetOrdersByBiblionumber); +use Koha::AuthorisedValues; +use Koha::Patrons; use Koha::Virtualshelves; my $query = CGI->new(); @@ -59,6 +60,7 @@ my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( ); my $biblionumber = $query->param('biblionumber'); +$biblionumber = HTML::Entities::encode($biblionumber); my $record = GetMarcBiblio($biblionumber); if ( not defined $record ) { @@ -84,9 +86,18 @@ my $showallitems = $query->param('showallitems'); 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") ); @@ -117,14 +128,14 @@ my $marchostsarray = GetMarcHosts($record,$marcflavour); my $subtitle = GetRecordValue('subtitle', $record, $fw); # Get Branches, Itemtypes and Locations -my $branches = GetBranches(); my $itemtypes = GetItemTypes(); my $dbh = C4::Context->dbh; my @all_items = GetItemsInfo( $biblionumber ); my @items; +my $patron = Koha::Patrons->find( $borrowernumber ); for my $itm (@all_items) { - push @items, $itm unless ( $itm->{itemlost} && GetHideLostItemsPreference($borrowernumber) && !$showallitems); + push @items, $itm unless ( $itm->{itemlost} && $patron->category->hidelostitems && !$showallitems); } # flag indicating existence of at least one item linked via a host record @@ -151,7 +162,6 @@ foreach my $subscription (@subscriptions) { $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}; @@ -181,13 +191,34 @@ $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->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) }; +my $collections = + { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) }; +my $copynumbers = + { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_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 @@ -206,11 +237,7 @@ foreach my $item (@items) { : ''; $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'}; @@ -237,7 +264,7 @@ foreach my $item (@items) { $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; @@ -248,8 +275,8 @@ foreach my $item (@items) { 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; } @@ -275,7 +302,10 @@ foreach my $item (@items) { } 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') ) { @@ -378,7 +408,7 @@ $template->param( subscriptions => \@subs, subscriptionsnumber => $subscriptionsnumber, subscriptiontitle => $dat->{title}, - searchid => $query->param('searchid'), + searchid => scalar $query->param('searchid'), ); # $debug and $template->param(debug_display => 1);