From a6be577937369567efc7eec8542674a3b821496a Mon Sep 17 00:00:00 2001 From: lbrun <leo@sandbox.pergame.net> Date: Tue, 1 Dec 2015 12:14:21 +0100 Subject: [PATCH] dev#25892_module_de_demande_de_consultation_sur_place : condition display consultation links --- library/Class/Exemplaire.php | 6 +- .../View/Helper/Notice/Exemplaires.php | 343 ++---------------- .../View/Helper/Notice/ExemplairesTable.php | 343 ++++++++++++++++++ .../controllers/NoticeAjaxControllerTest.php | 46 ++- 4 files changed, 414 insertions(+), 324 deletions(-) create mode 100644 library/ZendAfi/View/Helper/Notice/ExemplairesTable.php diff --git a/library/Class/Exemplaire.php b/library/Class/Exemplaire.php index 4e861710b87..8b683ae7d0c 100644 --- a/library/Class/Exemplaire.php +++ b/library/Class/Exemplaire.php @@ -46,7 +46,8 @@ class Class_Exemplaire extends Storm_Model_Abstract { 'genre' => null, 'url' => null, 'emplacement' => '', - 'date_nouveaute' => '']; + 'date_nouveaute' => '', + 'zone995' => '']; protected $_sigb_exemplaire; @@ -205,6 +206,9 @@ class Class_Exemplaire extends Storm_Model_Abstract { return $sigbExemplaire->isReservable(); } + public function canConsult() { + return ($this->getSubfield('r') == 'PATIMP'); + } public function getSubfield($id) { $fields = $this->zone995toArray(); diff --git a/library/ZendAfi/View/Helper/Notice/Exemplaires.php b/library/ZendAfi/View/Helper/Notice/Exemplaires.php index 720f7a1f31b..efdc6f7fffd 100644 --- a/library/ZendAfi/View/Helper/Notice/Exemplaires.php +++ b/library/ZendAfi/View/Helper/Notice/Exemplaires.php @@ -21,15 +21,18 @@ class ZendAfi_View_Helper_Notice_Exemplaires extends ZendAfi_View_Helper_BaseHelper { protected $renderers = []; - + protected $exemplaires =[]; + protected $exemplaires_array =[]; public function Notice_Exemplaires($exemplaires, $nb_notices_oeuvre=0, $aff="normal") { $preferences = Class_Profil::getCurrentProfil()->getCfgNoticeAsArray()['exemplaires']; if (!$exemplaires) return false; - - return ($preferences['grouper'] == 0) - ? $this->view->Notice_Exemplaires_RenderByGroup($exemplaires, $preferences, $nb_notices_oeuvre, $aff) + $this->exemplaires=$exemplaires; + $render= ($preferences['grouper'] == 0) ? + $this->view->Notice_Exemplaires_RenderByGroup($exemplaires, $preferences, $nb_notices_oeuvre, $aff) : $this->view->Notice_Exemplaires_RenderByItem($exemplaires, $preferences, $nb_notices_oeuvre, $aff); + + return $render; } @@ -82,14 +85,23 @@ class ZendAfi_View_Helper_Notice_Exemplaires extends ZendAfi_View_Helper_BaseHel return $this->_tag('tr', $html); } + protected function consultationDisplay() { + foreach($this->exemplaires as $ex) { + if ($ex->canConsult()) + return true; + } + return false; + } + protected function _getRenderers($exemplaires, $preferences, $aff) { $renderers = []; - $names = ZendAfi_View_Helper_Notice_Exemplaires_Abstract::renderersNameFor($preferences, - $aff); + $names = ZendAfi_View_Helper_Notice_ExemplairesTable::renderersNameFor($preferences, + $aff,$this->consultationDisplay()); foreach($names as $name) { - $renderer = $this->view->getHelper(ZendAfi_View_Helper_Notice_Exemplaires_Abstract::NAME_PREFIX . $name); - $renderer->setExemplaires($exemplaires); + $renderer = $this->view->getHelper(ZendAfi_View_Helper_Notice_ExemplairesTable::NAME_PREFIX . $name); + $renderer->setExemplairesArray($exemplaires); + $renderer->setExemplaires($this->exemplaires); $renderers[] = $renderer; } @@ -152,6 +164,7 @@ class ZendAfi_View_Helper_Notice_Exemplaires extends ZendAfi_View_Helper_BaseHel class ZendAfi_View_Helper_Notice_Exemplaires_RenderByGroup extends ZendAfi_View_Helper_Notice_Exemplaires { public function Notice_Exemplaires_RenderByGroup($exemplaires, $preferences, $nb_notices_oeuvre=0, $aff="normal") { $group_exemplaires = []; + $this->exemplaires = $exemplaires; foreach($this->exemplairesToRows($exemplaires) as $ex) { $group_key = $ex['id_notice'].'_'.$ex['id_bib'].'_'.$ex['cote']; if (!isset($group_exemplaires[$group_key])) @@ -205,318 +218,4 @@ class ZendAfi_View_Helper_Notice_Exemplaires_RenderByItem extends ZendAfi_View_H -class ZendAfi_View_Helper_Notice_Exemplaires_Abstract extends ZendAfi_View_Helper_BaseHelper { - const NAME_PREFIX = 'Notice_Exemplaires_'; - protected $_exemplaires; - - - public static function renderersNameFor($preferences, $display_mode) { - $mapping = ['Num' => true, - 'Bib' => $preferences['bib'] == 1, - 'Annexe' => $preferences['annexe'] == 1, - 'Section' => $preferences['section'] == 1, - 'Emplacement' => $preferences['emplacement'] == 1, - 'Grouper' => $preferences['grouper'] == 0, - 'Cote' => true, - 'Dispo' => $preferences['dispo'] == 1, - 'DateRetour' => $preferences['date_retour'] == 1, - 'Localisation' => $preferences['localisation'] == 1, - 'Plan' => $preferences['plan'] == 1, - 'Resa' => $preferences['resa'] == 1 && $display_mode == 'normal', - 'Consultation' => true, - 'Oeuvre' => $display_mode == 'oeuvre']; - - $names = array_filter($mapping); - return array_keys($names); - } - - - protected static function _isActive($preferences, $name) { - return isset($preferences[$name]) && 1 == $preferences[$name]; - } - - - public function setExemplaires($exemplaires) { - $this->_exemplaires = $exemplaires; - } - - - public function renderHead() { - return $this->_tag('th', $this->getLibelle(), - ['class' => $this->getHeadClass(), - 'scope' => 'col']); - } - - - public function getHeadClass() { - $parts = explode('_', get_class($this)); - return Storm_Inflector::underscorize(end($parts)); - } - - - public function renderContent($exemplaire) { - return $this->_tag('td', $this->getContent($exemplaire), - ['class' => $this->getHeadClass()]); - } - - - public function getContent($exemplaire) { - return ''; - } - - - public function getBib($exemplaire){ - return ($bib = Class_Bib::find($exemplaire['id_bib'])) - ? $bib - : new Class_Bib(); - } -} - - - -class ZendAfi_View_Helper_Notice_Exemplaires_Bib extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - public function getLibelle() { - return $this->_('Bibliothèque'); - } - - - public function getContent($exemplaire) { - return $this->getBib($exemplaire)->getLibelle(); - } -} - - - -class ZendAfi_View_Helper_Notice_Exemplaires_Annexe extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - public function getLibelle() { - return $this->_('Bibliothèque'); - } - - public function getContent($exemplaire) { - if(!$exemplaire["annexe"]) - return " "; - if (!$annexe=Class_CodifAnnexe::findFirstBy(['id_bib'=> $exemplaire["id_bib"], - 'code' => $exemplaire["annexe"]])) - return " "; - return $annexe->getLibelle(); - } - -} - - - -class ZendAfi_View_Helper_Notice_Exemplaires_Section extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - public function getLibelle() { - return $this->_('Section'); - } - - public function getContent($exemplaire) { - return Class_Codification::getLibelleFacette("S".$exemplaire["section"]); - } - -} - - - -class ZendAfi_View_Helper_Notice_Exemplaires_Grouper extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - public function getLibelle() { - return $this->_('Exemplaires'); - } - - public function getContent($exemplaire) { - return $exemplaire["count(*)"].' ex.'; - } - -} - - - -class ZendAfi_View_Helper_Notice_Exemplaires_Dispo extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - public function getLibelle() { - return $this->_('Disponibilité'); - } - - public function renderContent($exemplaire) { - $class_dispo=''; - $libelle = $exemplaire["dispo"]; - $class_dispo = ($libelle == Class_WebService_SIGB_Exemplaire::DISPO_LIBRE) - ? '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>' - .$this->view->_plural($exemplaire['nb_resas'], - '','Nb résa: %s ', - 'Nb résas: %s ', - $exemplaire['nb_resas']) - .'</span>'; - - - return '<td class="dispo '.$class_dispo.'">'.$libelle.'</td>'; - } -} - - - -class ZendAfi_View_Helper_Notice_Exemplaires_Cote extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - public function getLibelle() { - return $this->_('Cote').$this->editionLabel($this->_exemplaires); - - } - - public function editionLabel($exemplaires) { - foreach($exemplaires as $ex){ - return (isset($ex["edition"]) && ($ex["edition"]!='') ? '<span>('.$this->_("Edition").')</span>' : ''); - } - } - - public function getContent($exemplaire) { - return $exemplaire["cote"].(isset($exemplaire["edition"]) && ($exemplaire["edition"]!='') - ? '<span>'.$exemplaire["edition"].'</span>' - : ''); - - } -} - - - -class ZendAfi_View_Helper_Notice_Exemplaires_DateRetour extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - public function getLibelle() { - return $this->_('Retour'); - } - public function getContent($exemplaire) { - return isset($exemplaire['date_retour']) ? $exemplaire['date_retour'] : NULL; - } - - -} - - - -class ZendAfi_View_Helper_Notice_Exemplaires_Localisation extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - public function getLibelle() { - return $this->_('Situer'); - } - - public function renderContent($exemplaire) { - $html='<td class="localisation" style="text-align:center">'; - - - $onclick="localisationExemplaire(this,".$exemplaire["id_bib"].",'".$exemplaire["cote"]."','".$exemplaire["code_barres"]."')"; - if ($this->getBib($exemplaire)->numberOfLocalisations()>0) - $html.= sprintf('<img src="%s" border="0" title="%s" style="cursor:pointer" onclick="%s" alt="%s" />', - URL_ADMIN_IMG.'picto/localisation.png', - $this->_('Situer cet exemplaire dans la bibliothèque'), - $onclick, - $this->_('Situer en exemplaire')); - else - $html.=' '; - $html.='</td>'; - return $html; - } - -} - - - -class ZendAfi_View_Helper_Notice_Exemplaires_Plan extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - public function getLibelle() { - return $this->_('Plan'); - } - - public function renderContent($exemplaire) { - $html='<td class="gmap" style="text-align:center;">'; - - if($this->getBib($exemplaire)->getGoogleMap() > "") - $html .= sprintf('<a href="%s"><img src="%s" border="0" alt="%s" title="%s" /></a>', - BASE_URL.'/bib/mapview?id_bib='.$exemplaire["id_bib"].'&retour=notice', - URL_ADMIN_IMG.'picto/map.gif', - $this->_('Afficher la carte'), - $this->_('Afficher la carte')); - else $html.=' '; - $html.='</td>'; - return $html; - } - -} - - - -class ZendAfi_View_Helper_Notice_Exemplaires_Resa extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - public function getLibelle() { - return $this->_('Réserver'); - } - - public function renderContent($exemplaire) { - return $this->view->Notice_ReservationLink($this->getBib($exemplaire), $exemplaire, ''); - } - -} - - -class ZendAfi_View_Helper_Notice_Exemplaires_Consultation extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - public function getLibelle() { - return $this->_('Consultation sur place'); - } - - public function renderContent($exemplaire) { - return $this->view->Notice_ConsultationLink($this->getBib($exemplaire), $exemplaire, ''); - } - -} - - - -class ZendAfi_View_Helper_Notice_Exemplaires_Oeuvre extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - public function getLibelle() { - return $this->_('Voir'); - } - - public function renderContent($exemplaire) { - - $html='<td class="oeuvre" style="text-align:center;">'; - $html.= sprintf('<a href="%s"> <img src="%s" border="0" alt="%s" title="%s" /></a>', - $this->view->url(['controller' => 'recherche', - 'action' => 'viewnotice', - 'id' => $exemplaire["id_notice"]]), - URL_IMG.'bouton/loupe.gif', - $this->_('Afficher la notice'), - $this->_('Afficher la notice') - ); - $html.='</td>'; - return $html; - - } - -} - - - -class ZendAfi_View_Helper_Notice_Exemplaires_Num extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - protected $num=0; - public function getLibelle() { - return $this->_('n°'); - } - - public function getContent($exemplaire) { - return ++$this->num; - } -} - - - -class ZendAfi_View_Helper_Notice_Exemplaires_Emplacement extends ZendAfi_View_Helper_Notice_Exemplaires_Abstract { - public function getLibelle() { - return $this->_('Emplacement'); - } - - public function getContent($exemplaire) { - return Class_Codification::getLibelleFacette("E".$exemplaire["emplacement"]); - } -} ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Notice/ExemplairesTable.php b/library/ZendAfi/View/Helper/Notice/ExemplairesTable.php new file mode 100644 index 00000000000..66236c59a59 --- /dev/null +++ b/library/ZendAfi/View/Helper/Notice/ExemplairesTable.php @@ -0,0 +1,343 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_View_Helper_Notice_ExemplairesTable extends ZendAfi_View_Helper_BaseHelper { + const NAME_PREFIX = 'Notice_Exemplaires_'; + protected $_exemplaires; + protected $exemplaires =[]; + protected $exemplaires_array =[]; + + + public static function renderersNameFor($preferences, $display_mode, $display_consultation) { + $mapping = ['Num' => true, + 'Bib' => $preferences['bib'] == 1, + 'Annexe' => $preferences['annexe'] == 1, + 'Section' => $preferences['section'] == 1, + 'Emplacement' => $preferences['emplacement'] == 1, + 'Grouper' => $preferences['grouper'] == 0, + 'Cote' => true, + 'Dispo' => $preferences['dispo'] == 1, + 'DateRetour' => $preferences['date_retour'] == 1, + 'Localisation' => $preferences['localisation'] == 1, + 'Plan' => $preferences['plan'] == 1, + 'Resa' => $preferences['resa'] == 1 && $display_mode == 'normal', + 'Consultation' => $display_consultation, + 'Oeuvre' => $display_mode == 'oeuvre']; + + $names = array_filter($mapping); + return array_keys($names); + } + + + protected static function _isActive($preferences, $name) { + return isset($preferences[$name]) && 1 == $preferences[$name]; + } + + + public function setExemplaires($exemplaires) { + $this->exemplaires = $exemplaires; + } + + public function setExemplairesArray($exemplaires) { + $this->exemplaires_array = $exemplaires; + } + + + public function renderHead() { + return $this->_tag('th', $this->getLibelle(), + ['class' => $this->getHeadClass(), + 'scope' => 'col']); + } + + + public function getHeadClass() { + $parts = explode('_', get_class($this)); + return Storm_Inflector::underscorize(end($parts)); + } + + + public function renderContent($exemplaire) { + return $this->_tag('td', $this->getContent($exemplaire), + ['class' => $this->getHeadClass()]); + } + + + public function getContent($exemplaire) { + return ''; + } + + + public function getBib($exemplaire){ + return ($bib = Class_Bib::find($exemplaire['id_bib'])) + ? $bib + : new Class_Bib(); + } +} + + + +class ZendAfi_View_Helper_Notice_Exemplaires_Bib extends ZendAfi_View_Helper_Notice_ExemplairesTable { + public function getLibelle() { + return $this->_('Bibliothèque'); + } + + + public function getContent($exemplaire) { + return $this->getBib($exemplaire)->getLibelle(); + } +} + + + +class ZendAfi_View_Helper_Notice_Exemplaires_Annexe extends ZendAfi_View_Helper_Notice_ExemplairesTable { + public function getLibelle() { + return $this->_('Bibliothèque'); + } + + public function getContent($exemplaire) { + if(!$exemplaire["annexe"]) + return " "; + if (!$annexe=Class_CodifAnnexe::findFirstBy(['id_bib'=> $exemplaire["id_bib"], + 'code' => $exemplaire["annexe"]])) + return " "; + return $annexe->getLibelle(); + } + +} + + + +class ZendAfi_View_Helper_Notice_Exemplaires_Section extends ZendAfi_View_Helper_Notice_ExemplairesTable { + public function getLibelle() { + return $this->_('Section'); + } + + public function getContent($exemplaire) { + return Class_Codification::getLibelleFacette("S".$exemplaire["section"]); + } + +} + + + +class ZendAfi_View_Helper_Notice_Exemplaires_Grouper extends ZendAfi_View_Helper_Notice_ExemplairesTable { + public function getLibelle() { + return $this->_('Exemplaires'); + } + + public function getContent($exemplaire) { + return $exemplaire["count(*)"].' ex.'; + } + +} + + + +class ZendAfi_View_Helper_Notice_Exemplaires_Dispo extends ZendAfi_View_Helper_Notice_ExemplairesTable { + public function getLibelle() { + return $this->_('Disponibilité'); + } + + public function renderContent($exemplaire) { + $class_dispo=''; + $libelle = $exemplaire["dispo"]; + $class_dispo = ($libelle == Class_WebService_SIGB_Exemplaire::DISPO_LIBRE) + ? '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>' + .$this->view->_plural($exemplaire['nb_resas'], + '','Nb résa: %s ', + 'Nb résas: %s ', + $exemplaire['nb_resas']) + .'</span>'; + + + return '<td class="dispo '.$class_dispo.'">'.$libelle.'</td>'; + } +} + + + +class ZendAfi_View_Helper_Notice_Exemplaires_Cote extends ZendAfi_View_Helper_Notice_ExemplairesTable { + public function getLibelle() { + return $this->_('Cote').$this->editionLabel($this->exemplaires_array); + + } + + public function editionLabel($exemplaires) { + foreach($exemplaires as $ex){ + return (isset($ex["edition"]) && ($ex["edition"]!='') ? '<span>('.$this->_("Edition").')</span>' : ''); + } + } + + public function getContent($exemplaire) { + return $exemplaire["cote"].(isset($exemplaire["edition"]) && ($exemplaire["edition"]!='') + ? '<span>'.$exemplaire["edition"].'</span>' + : ''); + + } +} + + + +class ZendAfi_View_Helper_Notice_Exemplaires_DateRetour extends ZendAfi_View_Helper_Notice_ExemplairesTable { + public function getLibelle() { + return $this->_('Retour'); + } + public function getContent($exemplaire) { + return isset($exemplaire['date_retour']) ? $exemplaire['date_retour'] : NULL; + } + + +} + + + +class ZendAfi_View_Helper_Notice_Exemplaires_Localisation extends ZendAfi_View_Helper_Notice_ExemplairesTable { + public function getLibelle() { + return $this->_('Situer'); + } + + public function renderContent($exemplaire) { + $html='<td class="localisation" style="text-align:center">'; + + + $onclick="localisationExemplaire(this,".$exemplaire["id_bib"].",'".$exemplaire["cote"]."','".$exemplaire["code_barres"]."')"; + if ($this->getBib($exemplaire)->numberOfLocalisations()>0) + $html.= sprintf('<img src="%s" border="0" title="%s" style="cursor:pointer" onclick="%s" alt="%s" />', + URL_ADMIN_IMG.'picto/localisation.png', + $this->_('Situer cet exemplaire dans la bibliothèque'), + $onclick, + $this->_('Situer en exemplaire')); + else + $html.=' '; + $html.='</td>'; + return $html; + } + +} + + + +class ZendAfi_View_Helper_Notice_Exemplaires_Plan extends ZendAfi_View_Helper_Notice_ExemplairesTable { + public function getLibelle() { + return $this->_('Plan'); + } + + public function renderContent($exemplaire) { + $html='<td class="gmap" style="text-align:center;">'; + + if($this->getBib($exemplaire)->getGoogleMap() > "") + $html .= sprintf('<a href="%s"><img src="%s" border="0" alt="%s" title="%s" /></a>', + BASE_URL.'/bib/mapview?id_bib='.$exemplaire["id_bib"].'&retour=notice', + URL_ADMIN_IMG.'picto/map.gif', + $this->_('Afficher la carte'), + $this->_('Afficher la carte')); + else $html.=' '; + $html.='</td>'; + return $html; + } + +} + + + +class ZendAfi_View_Helper_Notice_Exemplaires_Resa extends ZendAfi_View_Helper_Notice_ExemplairesTable { + public function getLibelle() { + return $this->_('Réserver'); + } + + public function renderContent($exemplaire) { + return $this->view->Notice_ReservationLink($this->getBib($exemplaire), $exemplaire, ''); + } + +} + + +class ZendAfi_View_Helper_Notice_Exemplaires_Consultation extends ZendAfi_View_Helper_Notice_ExemplairesTable { + public function getLibelle() { + return $this->_('Consultation sur place'); + } + + public function renderContent($exemplaire) { + return $this->view->Notice_ConsultationLink($this->getBib($exemplaire), $exemplaire, ''); + } + +} + + + +class ZendAfi_View_Helper_Notice_Exemplaires_Oeuvre extends ZendAfi_View_Helper_Notice_ExemplairesTable { + public function getLibelle() { + return $this->_('Voir'); + } + + public function renderContent($exemplaire) { + + $html='<td class="oeuvre" style="text-align:center;">'; + $html.= sprintf('<a href="%s"> <img src="%s" border="0" alt="%s" title="%s" /></a>', + $this->view->url(['controller' => 'recherche', + 'action' => 'viewnotice', + 'id' => $exemplaire["id_notice"]]), + URL_IMG.'bouton/loupe.gif', + $this->_('Afficher la notice'), + $this->_('Afficher la notice') + ); + $html.='</td>'; + return $html; + + } + +} + + + +class ZendAfi_View_Helper_Notice_Exemplaires_Num extends ZendAfi_View_Helper_Notice_ExemplairesTable { + protected $num=0; + public function getLibelle() { + return $this->_('n°'); + } + + public function getContent($exemplaire) { + return ++$this->num; + } +} + + + +class ZendAfi_View_Helper_Notice_Exemplaires_Emplacement extends ZendAfi_View_Helper_Notice_ExemplairesTable { + public function getLibelle() { + return $this->_('Emplacement'); + } + + public function getContent($exemplaire) { + return Class_Codification::getLibelleFacette("E".$exemplaire["emplacement"]); + } +} +?> \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index 9003713f5cb..116663ce22c 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -771,16 +771,60 @@ class NoticeAjaxControllerExemplairesWithIdBibs extends NoticeAjaxControllerExem $this->assertNotXPathContentContains('//td[@class="cote"]','VOD-T-DLJ'); } +} + + + + +class NoticeAjaxControllerWithItemOnSiteConsultationTest extends NoticeAjaxControllerExemplairesTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setup(); + + $this->fixture('Class_Notice', ['id' => 135, + 'clef_oeuvre' => 'AAA', + 'exemplaires' => [$this->fixture('Class_Exemplaire', ['id' =>799, + 'id_notice' => 135, + 'id_bib' => 99, + 'id_int_bib' => 4, + 'zone995' => serialize([['clef' => 'r', 'valeur' => 'PATIMP']]), + 'cote' => 'VOD', + 'dispo' => 'Disponible'])]]); + } + /** @test */ - public function consultationTitleShouldBeDisplayed() { + public function consultationShouldNotBeDisplayed() { + $this->dispatch('noticeajax/exemplaires/id/123', true); + $this->assertNotXPathContentContains('//th[@class="consultation"]','Consultation sur place',$this->_response->getBody()); + } + + + /** @test */ + public function reservationShouldBeDisplayed() { + $this->dispatch('noticeajax/exemplaires/id/123', true); + $this->assertXPathContentContains('//th[@class="resa"]',utf8_encode('Réserver'), $this->_response->getBody()); + } + + + /** @test */ + public function consultationShouldBeDisplayed() { + $this->dispatch('noticeajax/exemplaires/id/135', true); $this->assertXPathContentContains('//th[@class="consultation"]','Consultation sur place',$this->_response->getBody()); } + + /** @disabled-test */ + public function reservationShouldNotBeDisplayed() { + $this->dispatch('noticeajax/exemplaires/id/135', true); + $this->assertNotXPathContentContains('//th[@class="resa"]',utf8_encode('Réserver'), $this->_response->getBody()); + } } + class NoticeAjaxControllerExemplairesTest extends NoticeAjaxControllerExemplairesTestCase { -- GitLab