From db5c32a7b9ebc793b62f6e9f74cd28257ba5faf6 Mon Sep 17 00:00:00 2001
From: Alex Arnaud <alex.arnaud@biblibre.com>
Date: Thu, 4 Jun 2015 15:58:12 +0200
Subject: [PATCH] dev #17871 oaista la vista

Display external URL in availability column in items table
---
 .../php/classes/classe_profil_donnees.php     |  4 ++++
 library/Class/Exemplaire.php                  |  1 +
 .../View/Helper/Notice/Exemplaires.php        |  4 ++++
 .../View/Helper/Notice/ExemplairesTest.php    | 23 ++++++++++++++++++-
 4 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/cosmogramme/php/classes/classe_profil_donnees.php b/cosmogramme/php/classes/classe_profil_donnees.php
index 0d8fae87b4d..fecfec429c9 100644
--- a/cosmogramme/php/classes/classe_profil_donnees.php
+++ b/cosmogramme/php/classes/classe_profil_donnees.php
@@ -117,6 +117,10 @@ class profil_donnees {
 		$profil["format"]=$this->format;
 		$profil["attributs"]=$this->attributs;
 		if(!$profil["attributs"][0]["champ_cote"]) $profil["attributs"][0]["champ_cote"]="k";
+
+		if(!isset($profil["attributs"][0]["champ_url"]))
+			$profil["attributs"][0]["champ_url"] = ['zone' => '', 'champ' => ''];
+
 		return $profil;
 	}
 
diff --git a/library/Class/Exemplaire.php b/library/Class/Exemplaire.php
index b4591e04ee7..a71dd9f327f 100644
--- a/library/Class/Exemplaire.php
+++ b/library/Class/Exemplaire.php
@@ -44,6 +44,7 @@ class Class_Exemplaire extends Storm_Model_Abstract {
 																					'is_available' => false,
 																					'section' => '',
 																					'genre' => null,
+																					'url' => null,
 																					'emplacement' => '',
 																					'date_nouveaute' => ''];
 
diff --git a/library/ZendAfi/View/Helper/Notice/Exemplaires.php b/library/ZendAfi/View/Helper/Notice/Exemplaires.php
index 29d4275d9a7..56c0b885172 100644
--- a/library/ZendAfi/View/Helper/Notice/Exemplaires.php
+++ b/library/ZendAfi/View/Helper/Notice/Exemplaires.php
@@ -333,6 +333,10 @@ class ZendAfi_View_Helper_Notice_Exemplaires_Dispo extends ZendAfi_View_Helper_N
 			? 'disponible'
 			: '';
 
+		if ($exemplaire['url'])
+			$libelle = $this->view->tagAnchor($exemplaire['url'],
+																				$this->view->_('Description en ligne'));
+
 		if ( isset($exemplaire['nb_resas']) &&  $exemplaire['nb_resas']>0)
 			$libelle.=
 				'<span>'
diff --git a/tests/library/ZendAfi/View/Helper/Notice/ExemplairesTest.php b/tests/library/ZendAfi/View/Helper/Notice/ExemplairesTest.php
index 8259b96c9fd..fd9b2bc3b7e 100644
--- a/tests/library/ZendAfi/View/Helper/Notice/ExemplairesTest.php
+++ b/tests/library/ZendAfi/View/Helper/Notice/ExemplairesTest.php
@@ -59,6 +59,7 @@ class NoticeHtmlGetExemplairesWithOneExemplaireNoWebServiceTest extends ZendAfi_
 																		'cote' => 'DSEM',
 																		'dispo' => "Disponible",
 																		'code_barres' => "12345"]),
+
 										$this->fixture('Class_Exemplaire',
 																	 ['id' => 11,
 																		'id_bib' => -1,
@@ -67,8 +68,20 @@ class NoticeHtmlGetExemplairesWithOneExemplaireNoWebServiceTest extends ZendAfi_
 																		'annexe' => 'MOUL',
 																		'cote' => 'DSEM',
 																		'dispo' => "Disponible",
-																		'code_barres' => "12346"])
+																		'code_barres' => "12346"]),
+
+										$this->fixture('Class_Exemplaire',
+																	 ['id' => 12,
+																		'id_bib' => -1,
+																		'id_int_bib' => 0,
+																		'id_notice' => '24766',
+																		'annexe' => 'UPEC',
+																		'cote' => '',
+																		'dispo' => '',
+																		'code_barres' => '12347',
+																		'url' => 'http://www.sudoc.fr/05884144X'])
 		];
+
 		$this->html = $this->_helper->Notice_Exemplaires($exemplaires, 2);
 	}
 
@@ -92,6 +105,14 @@ class NoticeHtmlGetExemplairesWithOneExemplaireNoWebServiceTest extends ZendAfi_
 	}
 
 
+	/** @test */
+	public function thirdItemAvailabilityShouldDisplayLinkToSudoc() {
+		$this->assertXPathContentContains($this->html,
+																			'//td/a[@href="http://www.sudoc.fr/05884144X"]',
+																			'Description en ligne');
+	}
+
+
 	/** @test */
 	public function reservationLinkShouldBeRechercheReservation() {
 		$this->assertXPath(
-- 
GitLab