From 8af2fa69188039f29806f05f6cef37b7c13b5032 Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@afi-sa.fr>
Date: Tue, 13 Nov 2018 11:10:23 +0100
Subject: [PATCH] hotline #81316 : fix display of multiple summaries

---
 .../php/classes/classe_notice_integration.php   |  1 +
 library/Class/Notice.php                        | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/cosmogramme/php/classes/classe_notice_integration.php b/cosmogramme/php/classes/classe_notice_integration.php
index 012c58dc912..ce8740f2c38 100644
--- a/cosmogramme/php/classes/classe_notice_integration.php
+++ b/cosmogramme/php/classes/classe_notice_integration.php
@@ -941,6 +941,7 @@ class notice_integration {
     $unimarc_key = $this->notice["clef_unimarc"]
       ? $this->notice["clef_unimarc"]
       : $title_key;
+
     $values =['clef_chapeau' => $this->notice["clef_chapeau"],
               'clef_numero' => $this->notice["clef_numero"],
               'clef_unimarc' => $unimarc_key,
diff --git a/library/Class/Notice.php b/library/Class/Notice.php
index 9226dc793f0..67f5babf55d 100644
--- a/library/Class/Notice.php
+++ b/library/Class/Notice.php
@@ -600,6 +600,17 @@ class Class_Notice extends Storm_Model_Abstract {
     return $data;
   }
 
+  protected function existsInArray($array,$field,$value) {
+    foreach ($array as $model) {
+      if (!isset($model[$field]))
+        continue;
+      if ($model[$field] == $value)
+        return true;
+    }
+    return false;
+  }
+
+
 // ----------------------------------------------------------------
 // Renvoie les articles d'un périodique
 // ----------------------------------------------------------------
@@ -618,11 +629,15 @@ class Class_Notice extends Storm_Model_Abstract {
       $serial_article->getNoticeUnimarc()->setNotice($enreg->getUnimarc(), 0);
 
       $article = ["titre" => $serial_article->getTitrePrincipal()];
+
       if ($complement = $serial_article->getComplementTitre())
         $article["titre"] .= " : " . $complement;
-
+      if ($this->existsInArray($articles,'clef_unimarc',$enreg->getClefUnimarc()))
+        continue;
       $auteurs = $serial_article->getAuteursUnimarc(true);
+
       $article["auteur"] = isset($auteurs[0]) ? $auteurs[0] : '';
+      $article["clef_unimarc"] = $enreg->getClefUnimarc();
       $article["pagination"] = $serial_article->getCollation();
       $note = $data = $serial_article->get_subfield("300", "a");
       $article["note"] = isset($note[0]) ? trim($note[0]) : '';
-- 
GitLab