Bug 10006 - holding branch is not available to XSLT display
[koha.git] / C4 / XSLT.pm
index d17b828..19ce2ab 100644 (file)
@@ -166,9 +166,9 @@ sub XSLTParse4Display {
                        "slim2OPACResults.xsl";
         }
         $xslfilename = "$htdocs/$theme/$lang/xslt/$xslfile";
-        $xslfilename = "$htdocs/$theme/en/xslt/$xslfile" unless ( $lang ne 'en' && !-f $xslfilename );
-        $xslfilename = "$htdocs/prog/$lang/xslt/$xslfile" unless ( !-f $xslfilename );
-        $xslfilename = "$htdocs/prog/en/xslt/$xslfile" unless ( $lang ne 'en' && !-f $xslfilename );
+        $xslfilename = "$htdocs/$theme/en/xslt/$xslfile" unless ( $lang ne 'en' && -f $xslfilename );
+        $xslfilename = "$htdocs/prog/$lang/xslt/$xslfile" unless ( -f $xslfilename );
+        $xslfilename = "$htdocs/prog/en/xslt/$xslfile" unless ( $lang ne 'en' && -f $xslfilename );
     }
 
     if ( $xslfilename =~ m/\{langcode\}/ ) {
@@ -188,8 +188,9 @@ sub XSLTParse4Display {
                               UseAuthoritiesForTracings TraceSubjectSubdivisions
                               Display856uAsImage OPACDisplay856uAsImage 
                               UseControlNumber IntranetBiblioDefaultView BiblioDefaultView
-                              singleBranchMode
-                              AlternateHoldingsField AlternateHoldingsSeparator / )
+                              singleBranchMode OPACItemLocation DisplayIconsXSLT
+                              AlternateHoldingsField AlternateHoldingsSeparator
+                              TrackClicks / )
     {
         my $sp = C4::Context->preference( $syspref );
         next unless defined($sp);
@@ -220,7 +221,8 @@ sub XSLTParse4Display {
         $stylesheet->{$xslfilename} = $xslt->parse_stylesheet($style_doc);
     }
     my $results      = $stylesheet->{$xslfilename}->transform($source);
-    my $newxmlrecord = $stylesheet->{$xslfilename}->output_string($results);
+    my $newxmlrecord = $stylesheet->{$xslfilename}->output_as_chars($results);
+    #no need to decode with UTF-8 in header of XSLT templates: BZ 6554
     return $newxmlrecord;
 }
 
@@ -232,15 +234,21 @@ sub buildKohaItemsNamespace {
         my %hi = map {$_ => 1} @$hidden_items;
         @items = grep { !$hi{$_->{itemnumber}} } @items;
     }
+
+    my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
+    my $ccodes         = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
+
     my $branches = GetBranches();
     my $itemtypes = GetItemTypes();
+    my $location = "";
+    my $ccode = "";
     my $xml = '';
     for my $item (@items) {
         my $status;
 
         my ( $transfertwhen, $transfertfrom, $transfertto ) = C4::Circulation::GetTransfers($item->{itemnumber});
 
-       my ( $reservestatus, $reserveitem, undef ) = C4::Reserves::CheckReserves($item->{itemnumber});
+        my $reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber} );
 
         if ( $itemtypes->{ $item->{itype} }->{notforloan} || $item->{notforloan} || $item->{onloan} || $item->{wthdrawn} || $item->{itemlost} || $item->{damaged} || 
              (defined $transfertwhen && $transfertwhen ne '') || $item->{itemnotforloan} || (defined $reservestatus && $reservestatus eq "Waiting") ){ 
@@ -272,8 +280,14 @@ sub buildKohaItemsNamespace {
             $status = "available";
         }
         my $homebranch = $item->{homebranch}? xml_escape($branches->{$item->{homebranch}}->{'branchname'}):'';
-           my $itemcallnumber = xml_escape($item->{itemcallnumber});
+        my $holdingbranch = $item->{holdingbranch}? xml_escape($branches->{$item->{holdingbranch}}->{'branchname'}):'';
+        $location = $item->{location}? xml_escape($shelflocations->{$item->{location}}):'';
+        $ccode = $item->{ccode}? xml_escape($ccodes->{$item->{ccode}}):'';
+        my $itemcallnumber = xml_escape($item->{itemcallnumber});
         $xml.= "<item><homebranch>$homebranch</homebranch>".
+                "<holdingbranch>$holdingbranch</holdingbranch>".
+                "<location>$location</location>".
+                "<ccode>$ccode</ccode>".
                "<status>$status</status>".
                "<itemcallnumber>".$itemcallnumber."</itemcallnumber>"
         . "</item>";