From 63fe4f1f21bf19a41ce5f325fe9f1d4612c6bccd Mon Sep 17 00:00:00 2001 From: Ghislain Loas <ghislo@sandbox.pergame.net> Date: Mon, 23 Mar 2015 17:07:19 +0100 Subject: [PATCH] dev #22657 pnb user account add second table for pnb --- .../opac/views/scripts/abonne/prets.phtml | 53 ++++++++++++++++++- library/Class/User/Loans.php | 6 ++- library/Class/Users.php | 6 +++ .../ZendAfi/View/Helper/Abonne/LoanAction.php | 10 ++-- .../ZendAfi/View/Helper/TagDilicomWidget.php | 2 +- .../controllers/AbonneControllerPretsTest.php | 8 ++- 6 files changed, 76 insertions(+), 9 deletions(-) diff --git a/application/modules/opac/views/scripts/abonne/prets.phtml b/application/modules/opac/views/scripts/abonne/prets.phtml index 0bfd057baf1..84952b39c7a 100644 --- a/application/modules/opac/views/scripts/abonne/prets.phtml +++ b/application/modules/opac/views/scripts/abonne/prets.phtml @@ -27,7 +27,7 @@ if ($emprunts = $this->user->getEmprunts()) { <tbody> <?php $num = 1; - foreach ($this->user->getEmprunts() as $emprunt) { + foreach ($this->user->getEmprunts()->withoutPNB() as $emprunt) { $class_retard = $emprunt->isLate() ? 'class="pret_en_retard"' : '';?> <tr <?php echo $class_retard;?>> <td width="15px" align="center"><b><?php echo $num++;?></b></td> @@ -54,6 +54,57 @@ if ($emprunts = $this->user->getEmprunts()) { <?php } ?> </tbody> </table> +<br/> +<br/> + +<?php +if($this->user->hasPNB()) { +?> +<h2><?php echo $this->_('Prêts numériques en cours'); ?></h2> +<table width="100%" class="tablesorter"> + <thead> + <tr> + <th style="text-align:left; white-space:nowrap"><?php echo $this->_('n°'); ?></th> + <th style="text-align:left"><?php echo $this->_('Titre'); ?></th> + <th style="text-align:left"><?php echo $this->_('Auteur'); ?></th> + <th style="text-align:left"><?php echo $this->_('Bibliothèque'); ?></th> + <th style="text-align:center"><?php echo $this->_('Retour prévu'); ?></th> + <th style="text-align:center"><?php echo $this->_('Informations'); ?></th> + </tr> + </thead> + <tbody> + <?php + $num = 1; + foreach ($this->user->getEmprunts()->selectPNB() as $emprunt) { + $class_retard = $emprunt->isLate() ? 'class="pret_en_retard"' : '';?> + <tr <?php echo $class_retard;?>> + <td width="15px" align="center"><b><?php echo $num++;?></b></td> + <td> + <?php + echo $this->tagAnchor( + $this->url(['controller' => 'recherche', + 'action' => 'viewnotice', + 'id' => $emprunt->getNoticeOPACId(), + 'retour_abonne' => 'prets'], + null, true), + $emprunt->getTitre()); + ?></td> + <td><?php echo $emprunt->getAuteur();?></td> + <td><?php echo $emprunt->getBibliotheque();?></td> + <td class="date_retour"> + <?php + echo $emprunt->getDateRetour() . ' '; + echo $this->abonne_LoanAction($emprunt); + ?> + </td> + <td><?php echo $emprunt->getType();?></td> + </tr> + <?php } ?> + </tbody> +</table> +<?php +} +?> <?php $this->closeBoite(); ?> <?php echo $this->abonne_RetourFiche(); ?> diff --git a/library/Class/User/Loans.php b/library/Class/User/Loans.php index 4a67f4060f1..d20721ae4ab 100644 --- a/library/Class/User/Loans.php +++ b/library/Class/User/Loans.php @@ -24,10 +24,14 @@ class Class_User_Loans extends Storm_Model_Collection_Abstract { return $this->select(function($loan) {return $loan->isLate();}); } + public function withoutPNB() { return $this->reject(function($loan) {return $loan->isPNB();}); } -} + public function selectPNB() { + return $this->select(function($loan) {return $loan->isPNB();}); + } +} ?> \ No newline at end of file diff --git a/library/Class/Users.php b/library/Class/Users.php index da34cec596b..f105d829771 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -1034,6 +1034,12 @@ class Class_Users extends Storm_Model_Abstract { } + public function hasPNB() { + return 0 < Class_Loan_Pnb::countBy(['user_id' => $this->getId(), + 'ongoing' => true]); + } + + public function getPanierCourant() { return ($panier_courant = parent::getPanierCourant()) ? $panier_courant : Class_PanierNotice::newInstance(); } diff --git a/library/ZendAfi/View/Helper/Abonne/LoanAction.php b/library/ZendAfi/View/Helper/Abonne/LoanAction.php index bbcdf144f08..bfa773195c6 100644 --- a/library/ZendAfi/View/Helper/Abonne/LoanAction.php +++ b/library/ZendAfi/View/Helper/Abonne/LoanAction.php @@ -52,12 +52,12 @@ class ZendAfi_View_Helper_Abonne_LoanAction extends ZendAfi_View_Helper_Abonne_A public function endLoanBookLink($emprunt) { - return $this->tagAnchor([ - 'action' => 'end-loan-book', - 'id' => $emprunt->getId() - ], - $this->_('Rendre le livre')); + return $this->view->tagAnchor(['action' => 'end-loan-book', + 'id' => $emprunt->getId()], + $this->_('Rendre le livre')); } + + } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/TagDilicomWidget.php b/library/ZendAfi/View/Helper/TagDilicomWidget.php index 98e9b323c81..682038686a3 100644 --- a/library/ZendAfi/View/Helper/TagDilicomWidget.php +++ b/library/ZendAfi/View/Helper/TagDilicomWidget.php @@ -59,7 +59,7 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement protected function getLoanBookAnchor() { return $this->getDilicomAnchor(['controller' => 'bib-numerique', 'action' => 'loan-book', - 'id' => $this->_album->getId()], + 'id' => $this->_album->getId(),], $this->view->_('Emprunter le livre au format EPUB')); } diff --git a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php index 8029752316c..0f429f978b6 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php @@ -262,7 +262,7 @@ class AbonneControllerPretsListThreePretsTest extends AbonneControllerPretsListT /** @test */ public function pinocchioLoanShouldHaveLinkToEndLoanBook() { - $this->assertXPathContentContains("//td//a[@href='/abonne/end-loan-book/id/5'][@data-popup='true']", + $this->assertXPathContentContains("//td//a[@href='/abonne/end-loan-book/id/5']", 'Rendre le livre'); } @@ -308,6 +308,12 @@ class AbonneControllerPretsListThreePretsTest extends AbonneControllerPretsListT public function colonneInformationShouldContainsP1(){ $this->assertXPathContentContains('//tbody//td','P1', $this->_response->getBody()); } + + + /** @test */ + public function pnbH2TitleShouldBePresent() { + $this->assertXpathContentContains('//h2', utf8_encode('Prêts numériques en cours')); + } } -- GitLab