From d7408ad14e3bad5d20648449849b169e6d575269 Mon Sep 17 00:00:00 2001
From: Arthur Suzuki <arthur.suzuki@biblibre.com>
Date: Thu, 5 May 2022 17:29:51 +0200
Subject: [PATCH] Bug 30430 : (QA follow-up) fix display of 210 only if no 214
 + added 214r/s

Signed-off-by: David Nind <david@davidnind.com>
---
 .../en/xslt/UNIMARCslim2intranetDetail.xsl    |  4 +-
 .../en/xslt/UNIMARCslim2intranetResults.xsl   |  4 +-
 .../prog/en/xslt/UNIMARCslimUtils.xsl         | 53 +++++++++++++++++++
 .../en/xslt/UNIMARCslim2OPACDetail.xsl        |  4 +-
 .../en/xslt/UNIMARCslim2OPACResults.xsl       |  4 +-
 .../bootstrap/en/xslt/UNIMARCslimUtils.xsl    | 53 +++++++++++++++++++
 6 files changed, 110 insertions(+), 12 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetDetail.xsl
index afb896fe89..25a8d08dee 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetDetail.xsl
+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetDetail.xsl
@@ -138,9 +138,7 @@
     </span>
   </xsl:if>
 
-  <xsl:call-template name="tag_210" />
-
-  <xsl:call-template name="tag_214" />
+  <xsl:call-template name="tag_210-214" />
 
   <xsl:call-template name="tag_215" />
 
diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetResults.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetResults.xsl
index f982a6217e..624603c620 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetResults.xsl
+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetResults.xsl
@@ -73,9 +73,7 @@
 
   <xsl:call-template name="tag_4xx" />
 
-  <xsl:call-template name="tag_210" />
-
-  <xsl:call-template name="tag_214" />
+  <xsl:call-template name="tag_210-214" />
 
   <xsl:call-template name="tag_215" />
 
diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslimUtils.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslimUtils.xsl
index 419fe9d6d2..408fceb70a 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslimUtils.xsl
+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslimUtils.xsl
@@ -28,6 +28,20 @@
     </xsl:element>
   </xsl:template>
 
+  <xsl:template name="tag_210-214">
+    <xsl:choose>
+      <xsl:when test="marc:datafield[@tag=210] and marc:datafield[@tag=214]">
+	<xsl:call-template name="tag_214" />
+      </xsl:when>
+      <xsl:when test="marc:datafield[@tag=214]">
+	<xsl:call-template name="tag_214" />
+      </xsl:when>
+      <xsl:when test="marc:datafield[@tag=210]">
+	<xsl:call-template name="tag_210" />
+      </xsl:when>
+    </xsl:choose>
+  </xsl:template>
+
   <xsl:template name="tag_210">
     <span class="results_summary publication">
       <span class="label">Publication: </span>
@@ -153,6 +167,45 @@
         </span>
       </span>
     </xsl:for-each>
+    <xsl:call-template name="tag_214_r" />
+    <xsl:call-template name="tag_214_s" />
+  </xsl:template>
+
+  <xsl:template name="tag_214_s">
+    <xsl:if test="marc:datafield[@tag=214]/marc:subfield[@code='s']">
+      <span class="results_summary tag_214_s">
+	<span class="label">Printing and/or Publishing Information Transcribed as Found in the Colophon: </span>
+	<xsl:for-each select="marc:datafield[@tag=214]">
+	  <xsl:value-of select="marc:subfield[@code='s']"/>
+	  <xsl:choose>
+	    <xsl:when test="position()=last()">
+	      <xsl:text>.</xsl:text>
+	    </xsl:when>
+	    <xsl:otherwise><xsl:text>, </xsl:text>
+	    </xsl:otherwise>
+	  </xsl:choose>
+	</xsl:for-each>
+      </span>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template name="tag_214_r">
+    <xsl:if test="marc:datafield[@tag=214]/marc:subfield[@code='r']">
+      <span class="results_summary tag_214_r">
+	<span class="label">Printing and/or Publishing Information Transcribed as Found in the Main Source of
+	Information: </span>
+	<xsl:for-each select="marc:datafield[@tag=214]">
+	  <xsl:value-of select="marc:subfield[@code='r']"/>
+	  <xsl:choose>
+	    <xsl:when test="position()=last()">
+	      <xsl:text>.</xsl:text>
+	    </xsl:when>
+	    <xsl:otherwise><xsl:text>, </xsl:text>
+	    </xsl:otherwise>
+	  </xsl:choose>
+	</xsl:for-each>
+      </span>
+    </xsl:if>
   </xsl:template>
 
   <xsl:template name="tag_215">
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACDetail.xsl
index 3fab572ee9..f2bebe101f 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACDetail.xsl
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACDetail.xsl
@@ -186,9 +186,7 @@
     <xsl:with-param name="spanclass">edition</xsl:with-param>
   </xsl:call-template>
 
-  <xsl:call-template name="tag_210" />
-
-  <xsl:call-template name="tag_214" />
+  <xsl:call-template name="tag_210-214" />
 
   <xsl:call-template name="tag_215" />
 
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACResults.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACResults.xsl
index 2d6711fb12..b9d36a2d35 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACResults.xsl
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACResults.xsl
@@ -151,9 +151,7 @@
     <xsl:with-param name="spanclass">piece_analytic_level</xsl:with-param>
   </xsl:call-template>
 
-  <xsl:call-template name="tag_210" />
-
-  <xsl:call-template name="tag_214" />
+  <xsl:call-template name="tag_210-214" />
 
   <xsl:call-template name="tag_215" />
 
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslimUtils.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslimUtils.xsl
index bd8c1f430d..b5a970a2c7 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslimUtils.xsl
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslimUtils.xsl
@@ -189,6 +189,20 @@
     </xsl:if>
   </xsl:template>
 
+  <xsl:template name="tag_210-214">
+    <xsl:choose>
+      <xsl:when test="marc:datafield[@tag=210] and marc:datafield[@tag=214]">
+	<xsl:call-template name="tag_214" />
+      </xsl:when>
+      <xsl:when test="marc:datafield[@tag=214]">
+	<xsl:call-template name="tag_214" />
+      </xsl:when>
+      <xsl:when test="marc:datafield[@tag=210]">
+	<xsl:call-template name="tag_210" />
+      </xsl:when>
+    </xsl:choose>
+  </xsl:template>
+
   <xsl:template name="tag_210">
     <span class="results_summary publication">
       <span class="label">Publication: </span>
@@ -311,6 +325,45 @@
         </span>
       </span>
     </xsl:for-each>
+    <xsl:call-template name="tag_214_r" />
+    <xsl:call-template name="tag_214_s" />
+  </xsl:template>
+
+  <xsl:template name="tag_214_s">
+    <xsl:if test="marc:datafield[@tag=214]/marc:subfield[@code='s']">
+      <span class="results_summary tag_214_s">
+	<span class="label">Printing and/or Publishing Information Transcribed as Found in the Colophon: </span>
+	<xsl:for-each select="marc:datafield[@tag=214]">
+	  <xsl:value-of select="marc:subfield[@code='s']"/>
+	  <xsl:choose>
+	    <xsl:when test="position()=last()">
+	      <xsl:text>.</xsl:text>
+	    </xsl:when>
+	    <xsl:otherwise><xsl:text>, </xsl:text>
+	    </xsl:otherwise>
+	  </xsl:choose>
+	</xsl:for-each>
+      </span>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template name="tag_214_r">
+    <xsl:if test="marc:datafield[@tag=214]/marc:subfield[@code='r']">
+      <span class="results_summary tag_214_r">
+	<span class="label">Printing and/or Publishing Information Transcribed as Found in the Main Source of
+	formation: </span>
+	<xsl:for-each select="marc:datafield[@tag=214]">
+	  <xsl:value-of select="marc:subfield[@code='r']"/>
+	  <xsl:choose>
+	    <xsl:when test="position()=last()">
+	      <xsl:text>.</xsl:text>
+	    </xsl:when>
+	    <xsl:otherwise><xsl:text>, </xsl:text>
+	    </xsl:otherwise>
+	  </xsl:choose>
+	</xsl:for-each>
+      </span>
+    </xsl:if>
   </xsl:template>
 
   <xsl:template name="tag_215">
-- 
2.30.2