diff --git a/VERSIONS_WIP/49634 b/VERSIONS_WIP/49634 new file mode 100644 index 0000000000000000000000000000000000000000..d52e1c25476e503788339b469a1a6813c8e1dea7 --- /dev/null +++ b/VERSIONS_WIP/49634 @@ -0,0 +1,2 @@ + - ticket #49634 : Réservation : Lorsque le choix du site de retrait est activé dans la configuration cosmogramme, le site de l'abonné est pré-coché dans la liste des sites de retrait + \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Notice/ReservationLink.php b/library/ZendAfi/View/Helper/Notice/ReservationLink.php index 8074484a67301a69e4d87c3a6bdd22634eaf9e24..04a89d8ff019508bb902e77a51aa4c82757193bb 100644 --- a/library/ZendAfi/View/Helper/Notice/ReservationLink.php +++ b/library/ZendAfi/View/Helper/Notice/ReservationLink.php @@ -80,13 +80,29 @@ class ZendAfi_View_Helper_Notice_ReservationLink extends ZendAfi_View_Helper_Bas 'id_int_bib' => $ex->getIdIntBib(), 'id_bib' => $ex->getIdBib(), 'copy_id' => $ex->getId(), - 'code_annexe' => $ex->getCodeAnnexe()]); + 'code_annexe' => $this->_getBranchCode($ex)]); return $this->_tag('a', $this->_getHoldImage(), ['href' => $link, 'data-popup' => 'true']); } + protected function _getBranchCode($item) { + $item_branch_code = $item->getCodeAnnexe(); + + if(!Class_CosmoVar::isSiteRetraitResaChoiceEnabled()) + return $item_branch_code; + + if(!$user = Class_Users::getIdentity()) + return $item_branch_code; + + if(!$branch_code = $user->getLibraryCode()) + return $item_branch_code; + + return $branch_code; + } + + /** @return string */ protected function _getHoldImageUrl() { return Class_Profil::getCurrentProfil()->getUrlImage(self::HOLD_IMG); diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index 33e751c02ca1ee748075f336500162c929b22e19..46f8a290956842f42553549cab555a2a0f10f012 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -2299,3 +2299,66 @@ class NoticeAjaxControllerRecountsTest extends AbstractControllerTestCase { } } + + + + +class NoticeAjaxControllerNanookSIGBWithHoldSiteEnabledTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_CosmoVar', + ['id' => 'site_retrait_resa', + 'valeur' => 1]); + + $this->fixture('Class_Bib', + ['id' => 12, + 'libelle' => 'Library']); + + $this->fixture('Class_IntBib', + ['id' => 12, + 'comm_sigb' => Class_IntBib::COM_NANOOK, + 'comm_params' => ['url_serveur' => 'https://mynanook.org']]); + + $item_from_sigb = (new Class_Entity()) + ->whenCalledDo('isValid', function() {return true;}) + ->whenCalledDo('isReservable', function() {return true;}) + ->whenCalledDo('isDisponible', function() {return false;}) + ; + + $item = $this->fixture('Class_Exemplaire', + ['id' => 654, + 'cote' => '', + 'annexe' => 'POL', + 'id_bib' => 12, + 'id_int_bib' => 12]); + + $item->setSigbExemplaire($item_from_sigb); + + $this->fixture('Class_Notice', + ['id' => 10, + 'exemplaires' => [$item]]); + + $user_from_sigb = (new Class_Entity()) + ->whenCalledDo('getLibraryCode', function() {return 'CAV';}) + ; + + $user = $this->fixture('Class_Users', + ['id' => 789, + 'login' => 'Paul', + 'password' => 'passsss']) + ->beAbonneSIGB() + ->setFicheSIGB(['fiche' => $user_from_sigb]); + + ZendAfi_Auth::getInstance()->logUser($user); + $this->dispatch('/noticeajax/exemplaires/id_notice/10', true); + } + + + /** @test */ + public function holdLinkShouldContainsPaulBranchCode() { + $this->assertXPath('//table//a[@href="/recherche/reservation-pickup-ajax/id_notice/10/id_int_bib/12/id_bib/12/copy_id/654/code_annexe/CAV"]', $this->_response->getBody()); + } +} \ No newline at end of file