use Koha::ItemTypes;
use Koha::XSLT::Base;
use Koha::Libraries;
-
-
+use Koha::Recalls;
my $engine; #XSLT Handler object
my %authval_per_framework;
=head2 transformMARCXML4XSLT
Replaces codes with authorized values in a MARC::Record object
-Is only used in this module currently.
=cut
sub transformMARCXML4XSLT {
- my ($biblionumber, $record) = @_;
+ my ($biblionumber, $record, $opac) = @_;
my $frameworkcode = GetFrameworkCode($biblionumber) || '';
my $tagslib = &GetMarcStructure(1, $frameworkcode, { unsafe => 1 });
my @fields;
my @new_subfields = ();
for my $subfield ( $field->subfields() ) {
my ( $letter, $value ) = @$subfield;
- # Replace the field value with the authorised value *except* for MARC21/NORMARC field 942$n (suppression in opac)
+ # Replace the field value with the authorised value *except* for MARC21 field 942$n (suppression in opac)
if ( !( $tag eq '942' && $subfield->[0] eq 'n' ) || $marcflavour eq 'UNIMARC' ) {
- $value = GetAuthorisedValueDesc( $tag, $letter, $value, '', $tagslib )
+ $value = GetAuthorisedValueDesc( $tag, $letter, $value, '', $tagslib, undef, $opac )
if $av->{ $tag }->{ $letter };
}
push( @new_subfields, $letter, $value );
TrackClicks opacthemes IdRef OpacSuppression
OPACResultsLibrary OPACShowOpenURL
OpenURLResolverURL OpenURLImageLocation
- resultsMaxItems resultsMaxItemsUnavailable
+ OPACResultsMaxItems OPACResultsMaxItemsUnavailable OPACResultsUnavailableGroupingBy
OpenURLText OPACShowMusicalInscripts OPACPlayMusicalInscripts / )
{
my $sp = C4::Context->preference( $syspref );
my $variables = $params->{xslt_variables};
my $items_rs = $params->{items_rs};
+ die "Mandatory \$params->{xsl_syspref} was not provided, called with biblionumber $params->{biblionumber}"
+ if not defined $params->{xsl_syspref};
+
my $xslfilename = get_xsl_filename( $xslsyspref);
# grab the XML, run it through our stylesheet, push it out to the browser
my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
$variables ||= {};
+ my $biblio;
if (C4::Context->preference('OPACShowOpenURL')) {
my @biblio_itemtypes;
- my $biblio = Koha::Biblios->find($biblionumber);
+ $biblio //= Koha::Biblios->find($biblionumber);
if (C4::Context->preference('item-level_itypes')) {
@biblio_itemtypes = $biblio->items->get_column("itype");
} else {
$variables->{OpenURLResolverURL} = $biblio->get_openurl;
}
}
+
my $varxml = "<variables>\n";
while (my ($key, $value) = each %$variables) {
+ $value //= q{};
$varxml .= "<variable name=\"$key\">$value</variable>\n";
}
$varxml .= "</variables>\n";
my $ccodes =
{ map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => "", kohafield => 'items.ccode' } ) };
- my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' });
+ my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' })->as_list;
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
my $xml = '';
while ( my $item = $items->next ) {
my $status;
my $substatus = '';
+ my $recalls_count;
- if ($item->has_pending_hold) {
+ if ( C4::Context->preference('UseRecalls') ) {
+ $recalls_count = Koha::Recalls->search({ itemnumber => $item->itemnumber, status => 'waiting' })->count;
+ }
+
+ if ($recalls_count) {
+ # recalls take priority over holds
+ $status = 'other';
+ $substatus = 'Recall waiting';
+ }
+ elsif ( $item->has_pending_hold ) {
$status = 'other';
$substatus = 'Pending hold';
}
elsif ( $item->holds->waiting->count ) {
$status = 'other';
- $substatus = 'Waiting';
+ $substatus = 'Hold waiting';
}
elsif ($item->get_transfer) {
$status = 'other';
else {
$status = "available";
}
- my $homebranch = xml_escape($branches{$item->homebranch});
- my $holdingbranch = xml_escape($branches{$item->holdingbranch});
+ my $homebranch = C4::Koha::xml_escape($branches{$item->homebranch});
+ my $holdingbranch = C4::Koha::xml_escape($branches{$item->holdingbranch});
my $resultbranch = C4::Context->preference('OPACResultsLibrary') eq 'homebranch' ? $homebranch : $holdingbranch;
- my $location = xml_escape($item->location && exists $shelflocations->{$item->location} ? $shelflocations->{$item->location} : $item->location);
- my $ccode = xml_escape($item->ccode && exists $ccodes->{$item->ccode} ? $ccodes->{$item->ccode} : $item->ccode);
- my $itemcallnumber = xml_escape($item->itemcallnumber);
- my $stocknumber = xml_escape($item->stocknumber);
+ my $location = C4::Koha::xml_escape($item->location && exists $shelflocations->{$item->location} ? $shelflocations->{$item->location} : $item->location);
+ my $ccode = C4::Koha::xml_escape($item->ccode && exists $ccodes->{$item->ccode} ? $ccodes->{$item->ccode} : $item->ccode);
+ my $itemcallnumber = C4::Koha::xml_escape($item->itemcallnumber);
+ my $stocknumber = C4::Koha::xml_escape($item->stocknumber);
$xml .=
"<item>"
. "<homebranch>$homebranch</homebranch>"