diff --git a/application/modules/opac/views/scripts/recherche/viewnotice.phtml b/application/modules/opac/views/scripts/recherche/viewnotice.phtml index 5582487bd6749f03d8d7d0f718fe0870564dba87..ffc8e86f9e4f0e3703c804b7aa3d464d79a1e8b2 100644 --- a/application/modules/opac/views/scripts/recherche/viewnotice.phtml +++ b/application/modules/opac/views/scripts/recherche/viewnotice.phtml @@ -18,9 +18,13 @@ $script_loader = Class_ScriptLoader::getInstance() ['title' => $this->_('Retourner au résultat de recherche'), 'class' => 'retour']); - echo $this->tagPrintLink((new Class_Entity()) - ->setModels([$this->notice]) - ->setStrategy('Notice_View')); + echo Class_ModeleFusion::canPrintRecord() + ? $this->tagAnchor(['controller' => 'recherche', + 'action' => 'print'], + $this->_('Imprimer'), + ['title' => $this->_('Imprimer "%s"', $this->notice->getTitrePrincipal()), + 'target' => '_blank']) + : ''; echo $this->tagAnchor($this->url_panier, $this->_('Ajouter au panier'), diff --git a/library/Class/ModeleFusion.php b/library/Class/ModeleFusion.php index df9105b597b67dcfeb179ac7850676e9ccaf6020..a3c5f20a869385c503a1ceb8a7b6be41ed923a3e 100644 --- a/library/Class/ModeleFusion.php +++ b/library/Class/ModeleFusion.php @@ -53,6 +53,11 @@ class Class_ModeleFusionLoader extends Storm_Model_Loader { } + public function canPrintRecord() { + return 0 < Class_ModeleFusion::countBy(['type' => Class_ModeleFusion::RECORD_TEMPLATE]); + } + + public function getTrainingTemplateFor($training_page) { $names = ['EMARGEMENT' => Class_ModeleFusion::TRAINING_TEMPLATE.'EMARGEMENT', 'STAGIAIRES' => Class_ModeleFusion::TRAINING_TEMPLATE.'LISTE_STAGIAIRES', diff --git a/library/ZendAfi/Controller/Plugin/Printer/SearchResult.php b/library/ZendAfi/Controller/Plugin/Printer/SearchResult.php index 04fca8719127c18ca2e6901e6510398360f6c858..0037e60454dac5b03d50a3c88e87090e9be382c8 100644 --- a/library/ZendAfi/Controller/Plugin/Printer/SearchResult.php +++ b/library/ZendAfi/Controller/Plugin/Printer/SearchResult.php @@ -24,6 +24,24 @@ class ZendAfi_Controller_Plugin_Printer_SearchResult extends ZendAfi_Controller_Plugin_Printer_ModelFusion { protected function _getPrinterConfig() { + return $this->_getParam('id') + ? $this->_getOnePrinterConfig() + : $this->_getManyPrinterConfig(); + } + + + protected function _getOnePrinterConfig() { + $model_fusion = Class_ModeleFusion::getFusionForStrategyAndProfilOrDefault(Class_ModeleFusion::RECORD_TEMPLATE, + Class_Profil::getCurrentProfil()); + + return parent::_getPrinterConfig() + ->setStrategy($model_fusion->getType()) + ->setModelFusion($model_fusion->getId()) + ->setId($this->_getParam('id')); + } + + + protected function _getManyPrinterConfig() { $model_fusion = Class_ModeleFusion::getFusionForStrategyAndProfilOrDefault(Class_ModeleFusion::RECORDS_TEMPLATE, Class_Profil::getCurrentProfil()); diff --git a/library/ZendAfi/View/Helper/ListeNotices.php b/library/ZendAfi/View/Helper/ListeNotices.php index a48e848c12f5ae69045bf17a89aec989a7b661fb..e87940c182c8986030f8a8e186d5b8b3d99b761c 100644 --- a/library/ZendAfi/View/Helper/ListeNotices.php +++ b/library/ZendAfi/View/Helper/ListeNotices.php @@ -23,7 +23,7 @@ class ZendAfi_View_Helper_ListeNotices extends ZendAfi_View_Helper_BaseHelper { public function listeNotices($search_result) { $criteres_recherche = $search_result->getCriteresRecherche(); - $notices = $search_result->getRecords(); + $notices = $search_result->fetchRecords(); $nombre_resultats = $search_result->getRecordsCount(); $page = $criteres_recherche->getPage(); $preferences = $search_result->getSettings(); diff --git a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php index 34cb0c47c3ef0f0fc6adc71888cf034e08e44180..2a493eeae163fe7de9a19f42befa25d00430478d 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php @@ -140,7 +140,7 @@ class RechercheControllerPrintActionWithRecordsTest extends AbstractControllerTe -class RechercheControllerViewNoticePrintActionWithRecordsTest extends AbstractControllerTestCase { +class RechercheControllerPrintActionViewNoticeWithRecordsTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; public function setUp() { @@ -153,7 +153,7 @@ class RechercheControllerViewNoticePrintActionWithRecordsTest extends AbstractCo <div>{notice.resume} </div> {notice.avis[<p>{avis}</p>]} </p>', - 'type' => 'Notice_View']); + 'type' => Class_ModeleFusion::RECORD_TEMPLATE]); Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 12,