From 1cb60f06b27d88fdecbb0d7ef4781897c4559a48 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Tue, 22 Jan 2013 10:12:14 +0000
Subject: [PATCH] =?UTF-8?q?Dynix=20/=20Plaine:=20d=C3=A9sactive=20la=20r?=
 =?UTF-8?q?=C3=A9servation=20des=20exemplaires=20sur=20certains=20codes=20?=
 =?UTF-8?q?emplacement?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../Class/WebService/SIGB/Dynix/Service.php   |  1 +
 .../SIGB/Dynix/TitleInfoResponseReader.php    | 72 +++++++++++++++++++
 .../Class/WebService/SIGB/DynixFixtures.php   | 32 ++++++++-
 .../Class/WebService/SIGB/DynixTest.php       | 13 +++-
 4 files changed, 115 insertions(+), 3 deletions(-)

diff --git a/library/Class/WebService/SIGB/Dynix/Service.php b/library/Class/WebService/SIGB/Dynix/Service.php
index 424de66ff8f..743efa47ce3 100644
--- a/library/Class/WebService/SIGB/Dynix/Service.php
+++ b/library/Class/WebService/SIGB/Dynix/Service.php
@@ -92,6 +92,7 @@ class Class_Webservice_SIGB_Dynix_Service extends Class_WebService_SIGB_Abstract
 
 
 	public function reserverExemplaire($user, $exemplaire, $code_annexe){
+
 		return $this->_userHttpAction($user, 
 																	'createMyHold', 
 																	['titleKey' => $exemplaire->getIdOrigine(),
diff --git a/library/Class/WebService/SIGB/Dynix/TitleInfoResponseReader.php b/library/Class/WebService/SIGB/Dynix/TitleInfoResponseReader.php
index 782c3540156..a6e28cdfbfe 100644
--- a/library/Class/WebService/SIGB/Dynix/TitleInfoResponseReader.php
+++ b/library/Class/WebService/SIGB/Dynix/TitleInfoResponseReader.php
@@ -54,6 +54,75 @@ class Class_WebService_SIGB_Dynix_TitleInfoResponseReader extends Class_WebServi
 		'Z2ERREURS'=>'ERREURS Créteil'
 	];
 
+
+	protected $_emplacements_non_reservable = ['01ABBAYE',
+																						 '01ADICTION',
+																						 '01JDICTION',
+																						 '02AJDICTION',
+																						 '02MDIC',
+																						 '03ADICTION',
+																						 '03JDICTION',
+																						 '03PROINFOR',
+																						 '04JDICTION',
+																						 '05ADICTION',
+																						 '05JDICTION',
+																						 '06ADICTION',
+																						 '06JDICTION',
+																						 '07ADICTION',
+																						 '08ASERVINT',
+																						 '08DUHAMEL',
+																						 '08FA',
+																						 '08JSERVINT',
+																						 '08JFR',
+																						 '09ADICTION',
+																						 '09JDICTION',
+																						 '10AMUET',
+																						 '10AREFFL',
+																						 '10AREFMUL',
+																						 '10ASTG',
+																						 '10JLIVRANI',
+																						 '10JREFMUL',
+																						 '10JREFMUL',
+																						 '10MREFMUL',
+																						 '11REF',
+																						 '12CDROM',
+																						 '12DIC',
+																						 '12DOCA',
+																						 '12DOCJ',
+																						 '12DVD',
+																						 '12FAMUS',
+																						 '12MATORCH',
+																						 '12MATORCHJ',
+																						 '12MUSA',
+																						 '12MUSJ',
+																						 '12PEXE',
+																						 '12PMUSCH',
+																						 '12PMUSVOC',
+																						 '12PORCH',
+																						 '12PORCHP',
+																						 'ATTENTE',
+																						 'BINDERY',
+																						 'CATALOGING',
+																						 'DISCARD',
+																						 'ILL',
+																						 'INPROCESS',
+																						 'LONGOVRDUE',
+																						 'LOST',
+																						 'LOSTASSUM',
+																						 'LOSTCLAIM',
+																						 'LOST-PAID',
+																						 'MISSING',
+																						 'ONORDER',
+																						 'REFERENCE',
+																						 'REPAIR',
+																						 'RESERVES',
+																						 'RESHELVING',
+																						 'STACKS',
+																						 'UNKNOWN',
+																						 'Z1ERREURS1',
+																						 'Z1ERREURS2',
+																						 'Z2ERREURS'];
+
 	protected $_unvisible_code_dispo = [
 		'DISCARD','ILL','LONGOVRDUE','LOST','LOST-ASSUM','LOST-CLAIM','LOST-PAID','MISSING'
 	];
@@ -95,6 +164,9 @@ class Class_WebService_SIGB_Dynix_TitleInfoResponseReader extends Class_WebServi
 		if (!array_key_exists($this->_current_location_id,$this->_code_disponibilite) &&
 				$this->_current_location_id == $data)
 			$this->_current_exemplaire->setDisponibiliteLibre();
+
+		if (in_array($data, $this->_emplacements_non_reservable))
+			$this->_current_exemplaire->setReservable(false);
 	}
 
 
diff --git a/tests/library/Class/WebService/SIGB/DynixFixtures.php b/tests/library/Class/WebService/SIGB/DynixFixtures.php
index 08b98eca23e..98db636b93e 100644
--- a/tests/library/Class/WebService/SIGB/DynixFixtures.php
+++ b/tests/library/Class/WebService/SIGB/DynixFixtures.php
@@ -99,10 +99,38 @@ class DynixFixtures {
 
 
 	public static function xmlWithCurrentLocationId() {
-		return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><LookupTitleInfoResponse xmlns="http://schemas.sirsidynix.com/symws/standard"><TitleInfo><titleID>379804</titleID><TitleAvailabilityInfo><totalCopiesAvailable>1</totalCopiesAvailable><libraryWithAvailableCopies>Créteil : Réserve</libraryWithAvailableCopies><totalResvCopiesAvailable>0</totalResvCopiesAvailable><locationOfFirstAvailableItem>INPROCESS</locationOfFirstAvailableItem><holdable>false</holdable><bookable>false</bookable></TitleAvailabilityInfo><CallInfo><libraryID>CRETRES</libraryID><classificationID>ASIS</classificationID><callNumber>R TIT</callNumber><numberOfCopies>1</numberOfCopies><ItemInfo><itemID>00000001</itemID><itemTypeID>1IMP</itemTypeID><currentLocationID>INPROCESS</currentLocationID><homeLocationID>INPROCESS</homeLocationID><reshelvingLocationID>INPROCESS</reshelvingLocationID><chargeable>true</chargeable><fixedTimeBooking>false</fixedTimeBooking></ItemInfo></CallInfo></TitleInfo></LookupTitleInfoResponse>';
+		return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<LookupTitleInfoResponse xmlns="http://schemas.sirsidynix.com/symws/standard">
+	<TitleInfo>
+		<titleID>379804</titleID>
+		<TitleAvailabilityInfo>
+			<totalCopiesAvailable>1</totalCopiesAvailable>
+			<libraryWithAvailableCopies>Créteil : Réserve</libraryWithAvailableCopies>
+			<totalResvCopiesAvailable>0</totalResvCopiesAvailable>
+			<locationOfFirstAvailableItem>INPROCESS</locationOfFirstAvailableItem>
+			<holdable>true</holdable>
+			<bookable>false</bookable>
+		</TitleAvailabilityInfo>
+		<CallInfo>
+			<libraryID>CRETRES</libraryID>
+			<classificationID>ASIS</classificationID>
+			<callNumber>R TIT</callNumber>
+			<numberOfCopies>1</numberOfCopies>
+			<ItemInfo>
+				<itemID>00000001</itemID>
+				<itemTypeID>1IMP</itemTypeID>
+				<currentLocationID>INPROCESS</currentLocationID>
+				<homeLocationID>INPROCESS</homeLocationID>
+				<reshelvingLocationID>10AMUET</reshelvingLocationID>
+				<chargeable>true</chargeable>
+				<fixedTimeBooking>false</fixedTimeBooking>
+			</ItemInfo>
+		</CallInfo>
+	</TitleInfo>
+</LookupTitleInfoResponse>';
+	}
 
 
-	}
 	public static function xmlLookupTitleInfoHarryPotter() {
 		return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <LookupTitleInfoResponse xmlns="http://schemas.sirsidynix.com/symws/standard">
diff --git a/tests/library/Class/WebService/SIGB/DynixTest.php b/tests/library/Class/WebService/SIGB/DynixTest.php
index 7552cb63e05..aa5aadb92cb 100644
--- a/tests/library/Class/WebService/SIGB/DynixTest.php
+++ b/tests/library/Class/WebService/SIGB/DynixTest.php
@@ -80,8 +80,10 @@ abstract class DynixTestCase extends Storm_Test_ModelTestCase {
 
 
 
-class DynixCurrentLocationId extends DynixTestCase {
+
+class DynixCurrentLocationAsStatus extends DynixTestCase {
 	protected $_notice;
+
 	public function setUp() {
 		parent::setUp();
 
@@ -94,6 +96,7 @@ class DynixCurrentLocationId extends DynixTestCase {
 		$this->_notice = $this->_service->getNotice('379804');
 	}
 
+
 	/** @test */
 	public function firstExemplaireDisponibiliteShouldBeInProgress() {
 		$this->assertEquals('En traitement',
@@ -101,7 +104,15 @@ class DynixCurrentLocationId extends DynixTestCase {
 	}	
 
 
+	/** @test */
+	public function firstExemplaireShouldNotBeReservable() {
+		$this->assertFalse($this->_notice->exemplaireAt(0)->isReservable());
+	}	
 }
+
+
+
+
 class DynixGetNoticeLeCombatOrdinaire extends DynixTestCase {
 	protected $_notice;
 
-- 
GitLab